ti2-tourplan 1.0.30 → 1.0.32

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 +91 -62
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -177,6 +177,58 @@ class Plugin {
177
177
  }
178
178
  return R.path(['Reply'], replyObj);
179
179
  };
180
+
181
+ this.getPaxConfigs = (paxConfigs, noPaxList) =>
182
+ paxConfigs.map(({ roomType, passengers = [] }) => {
183
+ const RoomConfig = passengers.reduce((acc, p) => {
184
+ if (p.passengerType === 'Adult') {
185
+ acc.Adults += 1;
186
+ }
187
+ if (p.passengerType === 'Child') {
188
+ acc.Children += 1;
189
+ }
190
+ if (p.passengerType === 'Infant') {
191
+ acc.Infants += 1;
192
+ }
193
+ return acc;
194
+ }, {
195
+ Adults: 0,
196
+ Children: 0,
197
+ Infants: 0,
198
+ });
199
+ const RoomType = ({
200
+ Single: 'SG',
201
+ Double: 'DB',
202
+ Twin: 'TW',
203
+ Triple: 'TR',
204
+ Quad: 'QU',
205
+ })[roomType];
206
+ if (RoomType) RoomConfig.RoomType = RoomType;
207
+ if (passengers && passengers.length && !noPaxList) {
208
+ RoomConfig.PaxList = passengers.map(p => {
209
+ const PaxDetails = {
210
+ Forename: p.firstName,
211
+ Surname: p.lastName,
212
+ PaxType: {
213
+ Adult: 'A',
214
+ Child: 'C',
215
+ Infant: 'I',
216
+ }[p.passengerType] || 'A',
217
+ Title: p.salutation,
218
+ };
219
+ if (p.dob) PaxDetails.DateOfBirth = p.dob;
220
+ if (!isNaN(p.age)) {
221
+ if (!(p.passengerType === 'Adult' && p.age === 0)) {
222
+ PaxDetails.Age = p.age;
223
+ }
224
+ }
225
+ return {
226
+ PaxDetails,
227
+ };
228
+ });
229
+ }
230
+ return { RoomConfig };
231
+ });
180
232
  }
181
233
 
182
234
  async validateToken({
@@ -217,9 +269,11 @@ class Plugin {
217
269
  const replyObj = await this.callTourplan({
218
270
  model, endpoint, axios, xmlOptions: defaultXmlOptions,
219
271
  });
272
+ console.log(replyObj)
220
273
  assert(R.path(['AuthenticationReply'], replyObj) === '');
221
274
  return true;
222
275
  } catch (err) {
276
+ console.log(err)
223
277
  return false;
224
278
  }
225
279
  }
@@ -421,7 +475,6 @@ class Plugin {
421
475
  payload: {
422
476
  optionId,
423
477
  startDate,
424
- reference,
425
478
  /*
426
479
  paxConfigs: [{ roomType: 'DB', adults: 2 }, { roomType: 'TW', children: 2 }]
427
480
  */
@@ -441,22 +494,7 @@ class Plugin {
441
494
  Info: 'A',
442
495
  DateFrom: startDate,
443
496
  DateTo: startDate,
444
- RoomConfigs: paxConfigs.map(obj => {
445
- const RoomConfig = {
446
- Adults: obj.adults || 0,
447
- Children: obj.children || 0,
448
- Infants: obj.infants || 0,
449
- };
450
- const RoomType = ({
451
- Single: 'SG',
452
- Double: 'DB',
453
- Twin: 'TW',
454
- Triple: 'TR',
455
- Quad: 'QU',
456
- })[obj.roomType];
457
- if (RoomType) RoomConfig.RoomType = RoomType;
458
- return { RoomConfig };
459
- }),
497
+ RoomConfigs: this.getPaxConfigs(paxConfigs, true),
460
498
  AgentID: hostConnectAgentID,
461
499
  Password: hostConnectAgentPassword,
462
500
  },
@@ -481,6 +519,33 @@ class Plugin {
481
519
  -3 Available on request.
482
520
  Note: A return value of 0 or something less than -3 is impossible.
483
521
  */
522
+ if (optAvail === -1) {
523
+ return {
524
+ available: false,
525
+ };
526
+ }
527
+ if (optAvail === -2) {
528
+ return {
529
+ available: true,
530
+ type: 'free sell',
531
+ };
532
+ }
533
+ if (optAvail === -3) {
534
+ return {
535
+ available: true,
536
+ type: 'on request',
537
+ };
538
+ }
539
+ if (optAvail > 0) {
540
+ return {
541
+ available: true,
542
+ type: 'inventory',
543
+ quantity: optAvail,
544
+ };
545
+ }
546
+ return {
547
+ available: false,
548
+ };
484
549
  }
485
550
 
486
551
  async searchQuote({
@@ -527,14 +592,19 @@ class Plugin {
527
592
  RateId: rateId,
528
593
  } : {}),
529
594
  ...(puInfo ? {
530
- puTime: puInfo.time,
595
+ ...(puInfo.time && puInfo.time.replace(/\D/g, '') ? {
596
+ puTime: puInfo.time.replace(/\D/g, ''),
597
+ } : {}),
531
598
  puRemark: `Time: ${puInfo.time || 'NA'},
532
599
  Location: ${puInfo.location || 'NA'},
533
600
  Flight: ${puInfo.flightDetails || 'NA'},
534
601
  `,
535
602
  } : {}),
536
603
  ...(doInfo ? {
537
- doTime: doInfo.time,
604
+ // only get numbers from doInfo.time
605
+ ...(doInfo.time && doInfo.time.replace(/\D/g, '') ? {
606
+ doTime: doInfo.time.replace(/\D/g, ''),
607
+ } : {}),
538
608
  doRemark: `Time: ${doInfo.time || 'NA'},
539
609
  Location: ${doInfo.location || 'NA'},
540
610
  Flight: ${doInfo.flightDetails || 'NA'},
@@ -548,49 +618,7 @@ class Plugin {
548
618
  RateId: 'Default',
549
619
  SCUqty: chargeUnitQuanity || 1,
550
620
  AgentRef: reference,
551
- RoomConfigs: paxConfigs.map(({ roomType, passengers }) => {
552
- const RoomConfig = passengers.reduce((acc, p) => {
553
- if (p.passengerType === 'Adult') {
554
- acc.Adults += 1;
555
- }
556
- if (p.passengerType === 'Child') {
557
- acc.Children += 1;
558
- }
559
- if (p.passengerType === 'Infant') {
560
- acc.Infants += 1;
561
- }
562
- return acc;
563
- }, {
564
- Adults: 0,
565
- Children: 0,
566
- Infants: 0,
567
- });
568
- const RoomType = ({
569
- Single: 'SG',
570
- Double: 'DB',
571
- Twin: 'TW',
572
- Triple: 'TR',
573
- Quad: 'QU',
574
- })[roomType];
575
- if (RoomType) RoomConfig.RoomType = RoomType;
576
- if (passengers && passengers.length) {
577
- RoomConfig.PaxList = passengers.map(p => ({
578
- PaxDetails: {
579
- Forename: p.firstName,
580
- Surname: p.lastName,
581
- PaxType: {
582
- Adult: 'A',
583
- Child: 'C',
584
- Infant: 'I',
585
- }[p.passengerType],
586
- Age: p.age,
587
- DateOfBirth: p.dob,
588
- Title: p.salutation,
589
- },
590
- }));
591
- }
592
- return { RoomConfig };
593
- }),
621
+ RoomConfigs: this.getRoomConfigs(paxConfigs),
594
622
  },
595
623
  };
596
624
  const replyObj = await this.callTourplan({
@@ -676,6 +704,7 @@ class Plugin {
676
704
  const bookings = await Promise.map(bookingHeaders, async bookingHeader => {
677
705
  const getBookingPayload = getPayload('GetBookingRequest', {
678
706
  BookingId: R.prop('BookingId', bookingHeader),
707
+ ReturnAccountInfo: 'Y',
679
708
  });
680
709
  const bookingReply = await this.callTourplan(getBookingPayload);
681
710
  const booking = R.path(['GetBookingReply'], bookingReply);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ti2-tourplan",
3
- "version": "1.0.30",
3
+ "version": "1.0.32",
4
4
  "description": "Tourplan's TI2 Plugin",
5
5
  "main": "index.js",
6
6
  "scripts": {