ti2-ventrata 1.0.8 → 1.0.9

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 +14 -7
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -55,11 +55,11 @@ const rateMap = {
55
55
  };
56
56
 
57
57
  const availabilityMap = {
58
- dateTimeStart: R.path(['localDateTimeStart']),
59
- dateTimeEnd: R.path(['localDateTimeEnd']),
58
+ dateTimeStart: root => R.path(['localDateTimeStart'], root) || R.path(['localDate'], root),
59
+ dateTimeEnd: root => R.path(['localDateTimeEnd']) || R.path(['localDate'], root),
60
60
  allDay: R.path(['allDay']),
61
- pricing: R.path(['pricing']),
62
- unitPricing: R.path(['unitPricing']),
61
+ pricing: root => R.path(['pricing'], root) || R.path(['pricingFrom'], root),
62
+ unitPricing: root => R.path(['unitPricing'], root) || R.path(['unitPricingFrom'], root),
63
63
  offer: avail => (avail.offerCode ? doMap(avail, {
64
64
  offerId: R.path(['offerCode']),
65
65
  title: R.pathOr(undefined, ['offerTitle']),
@@ -379,7 +379,8 @@ class Plugin {
379
379
  optionIds,
380
380
  occupancies,
381
381
  startDate,
382
- // endDate,
382
+ endDate,
383
+ currency,
383
384
  dateFormat,
384
385
  },
385
386
  }) {
@@ -397,7 +398,7 @@ class Plugin {
397
398
  assert(optionIds.every(Boolean), 'some invalid optionId(s)');
398
399
  assert(occupancies.every(Boolean), 'some invalid occupacies(s)');
399
400
  const localDateStart = moment(startDate, dateFormat).format('YYYY-MM-DD');
400
- const localDateEnd = moment(startDate, dateFormat).format('YYYY-MM-DD');
401
+ const localDateEnd = moment(endDate, dateFormat).format('YYYY-MM-DD');
401
402
  // obtain the rates
402
403
  const { quote } = await this.searchQuote({
403
404
  token,
@@ -415,7 +416,7 @@ class Plugin {
415
416
  acceptLanguage,
416
417
  });
417
418
  const url = `${endpoint || this.endpoint}/availability/calendar`;
418
- const availability = (
419
+ let availability = (
419
420
  await Promise.map(rates, async (rate, rateIx) => {
420
421
  const qtys = R.countBy(x => x)(rate);
421
422
  const data = {
@@ -423,6 +424,7 @@ class Plugin {
423
424
  optionId: optionIds[rateIx],
424
425
  localDateStart,
425
426
  localDateEnd,
427
+ currency,
426
428
  units: Object.entries(qtys).map(([id, quantity]) => ({
427
429
  id, quantity,
428
430
  })),
@@ -435,6 +437,11 @@ class Plugin {
435
437
  });
436
438
  }, { concurrency: CONCURRENCY })
437
439
  ).map(({ data }) => data);
440
+ availability = availability.map(
441
+ (avails, availsIx) => (avails.map(
442
+ avail => doMap(avail, availabilityMap),
443
+ )),
444
+ );
438
445
  return { availability };
439
446
  }
440
447
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ti2-ventrata",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "Ventrata's TI2 Plugin",
5
5
  "main": "index.js",
6
6
  "scripts": {