ti2-tourplan 1.0.29 → 1.0.31

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 +101 -59
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -177,6 +177,51 @@ 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
+ PaxDetails: {
210
+ Forename: p.firstName,
211
+ Surname: p.lastName,
212
+ PaxType: {
213
+ Adult: 'A',
214
+ Child: 'C',
215
+ Infant: 'I',
216
+ }[p.passengerType],
217
+ Age: p.age,
218
+ ...(p.dob ? { DateOfBirth: p.dob } : {}),
219
+ Title: p.salutation,
220
+ },
221
+ }));
222
+ }
223
+ return { RoomConfig };
224
+ });
180
225
  }
181
226
 
182
227
  async validateToken({
@@ -217,9 +262,11 @@ class Plugin {
217
262
  const replyObj = await this.callTourplan({
218
263
  model, endpoint, axios, xmlOptions: defaultXmlOptions,
219
264
  });
265
+ console.log(replyObj)
220
266
  assert(R.path(['AuthenticationReply'], replyObj) === '');
221
267
  return true;
222
268
  } catch (err) {
269
+ console.log(err)
223
270
  return false;
224
271
  }
225
272
  }
@@ -421,7 +468,6 @@ class Plugin {
421
468
  payload: {
422
469
  optionId,
423
470
  startDate,
424
- reference,
425
471
  /*
426
472
  paxConfigs: [{ roomType: 'DB', adults: 2 }, { roomType: 'TW', children: 2 }]
427
473
  */
@@ -441,22 +487,7 @@ class Plugin {
441
487
  Info: 'A',
442
488
  DateFrom: startDate,
443
489
  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
- }),
490
+ RoomConfigs: this.getPaxConfigs(paxConfigs, true),
460
491
  AgentID: hostConnectAgentID,
461
492
  Password: hostConnectAgentPassword,
462
493
  },
@@ -481,6 +512,33 @@ class Plugin {
481
512
  -3 Available on request.
482
513
  Note: A return value of 0 or something less than -3 is impossible.
483
514
  */
515
+ if (optAvail === -1) {
516
+ return {
517
+ available: false,
518
+ };
519
+ }
520
+ if (optAvail === -2) {
521
+ return {
522
+ available: true,
523
+ type: 'free sell',
524
+ };
525
+ }
526
+ if (optAvail === -3) {
527
+ return {
528
+ available: true,
529
+ type: 'on request',
530
+ };
531
+ }
532
+ if (optAvail > 0) {
533
+ return {
534
+ available: true,
535
+ type: 'inventory',
536
+ quantity: optAvail,
537
+ };
538
+ }
539
+ return {
540
+ available: false,
541
+ };
484
542
  }
485
543
 
486
544
  async searchQuote({
@@ -492,6 +550,7 @@ class Plugin {
492
550
  },
493
551
  payload: {
494
552
  quoteName,
553
+ rateId,
495
554
  quoteId,
496
555
  // existingQuoteId,
497
556
  // existingLineId,
@@ -508,6 +567,9 @@ class Plugin {
508
567
  Defaults to 1.
509
568
  */
510
569
  chargeUnitQuanity,
570
+ extras,
571
+ puInfo,
572
+ doInfo,
511
573
  },
512
574
  }) {
513
575
  const model = {
@@ -519,53 +581,32 @@ class Plugin {
519
581
  } : {
520
582
  NewBookingInfo: { Name: quoteName, QB: 'Q' },
521
583
  }),
584
+ ...(rateId ? {
585
+ RateId: rateId,
586
+ } : {}),
587
+ ...(puInfo ? {
588
+ puTime: puInfo.time,
589
+ puRemark: `Time: ${puInfo.time || 'NA'},
590
+ Location: ${puInfo.location || 'NA'},
591
+ Flight: ${puInfo.flightDetails || 'NA'},
592
+ `,
593
+ } : {}),
594
+ ...(doInfo ? {
595
+ doTime: doInfo.time,
596
+ doRemark: `Time: ${doInfo.time || 'NA'},
597
+ Location: ${doInfo.location || 'NA'},
598
+ Flight: ${doInfo.flightDetails || 'NA'},
599
+ `,
600
+ } : {}),
601
+ ...(extras && extras.length ? {
602
+ Remarks: extras.map((e, i) => `Extra ${i + 1}: ${e.name} x ${e.quantity}`).join(`\n`),
603
+ } : {}),
522
604
  Opt: optionId,
523
605
  DateFrom: startDate,
524
606
  RateId: 'Default',
525
607
  SCUqty: chargeUnitQuanity || 1,
526
608
  AgentRef: reference,
527
- RoomConfigs: paxConfigs.map(({ roomType, passengers }) => {
528
- const RoomConfig = passengers.reduce((acc, p) => {
529
- if (p.passengerType === 'Adult') {
530
- acc.Adults += 1;
531
- }
532
- if (p.passengerType === 'Child') {
533
- acc.Children += 1;
534
- }
535
- if (p.passengerType === 'Infant') {
536
- acc.Infants += 1;
537
- }
538
- return acc;
539
- }, {
540
- Adults: 0,
541
- Children: 0,
542
- Infants: 0,
543
- });
544
- const RoomType = ({
545
- Single: 'SG',
546
- Double: 'DB',
547
- Twin: 'TW',
548
- Triple: 'TR',
549
- Quad: 'QU',
550
- })[roomType];
551
- if (RoomType) RoomConfig.RoomType = RoomType;
552
- if (passengers && passengers.length) {
553
- RoomConfig.PaxList = passengers.map(p => ({
554
- PaxDetails: {
555
- Forename: p.firstName,
556
- Surname: p.lastName,
557
- PaxType: {
558
- Adult: 'A',
559
- Child: 'C',
560
- Infant: 'I',
561
- }[p.passengerType],
562
- Age: p.age,
563
- Title: p.salutation,
564
- },
565
- }));
566
- }
567
- return { RoomConfig };
568
- }),
609
+ RoomConfigs: this.getRoomConfigs(paxConfigs),
569
610
  },
570
611
  };
571
612
  const replyObj = await this.callTourplan({
@@ -651,6 +692,7 @@ class Plugin {
651
692
  const bookings = await Promise.map(bookingHeaders, async bookingHeader => {
652
693
  const getBookingPayload = getPayload('GetBookingRequest', {
653
694
  BookingId: R.prop('BookingId', bookingHeader),
695
+ ReturnAccountInfo: 'Y',
654
696
  });
655
697
  const bookingReply = await this.callTourplan(getBookingPayload);
656
698
  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.29",
3
+ "version": "1.0.31",
4
4
  "description": "Tourplan's TI2 Plugin",
5
5
  "main": "index.js",
6
6
  "scripts": {