ti2-tourplan 1.0.37 → 1.0.38
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 +95 -49
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -201,7 +201,7 @@ class Plugin {
|
|
|
201
201
|
Double: 'DB',
|
|
202
202
|
Twin: 'TW',
|
|
203
203
|
Triple: 'TR',
|
|
204
|
-
Quad: '
|
|
204
|
+
Quad: 'QD',
|
|
205
205
|
})[roomType];
|
|
206
206
|
if (RoomType) RoomConfig.RoomType = RoomType;
|
|
207
207
|
if (passengers && passengers.length && !noPaxList) {
|
|
@@ -242,7 +242,12 @@ class Plugin {
|
|
|
242
242
|
.replace(/>/g, '>')
|
|
243
243
|
.replace(/"/g, '"')
|
|
244
244
|
.replace(/'/g, ''')
|
|
245
|
-
}
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
// this.errorPathsAxiosErrors = () => ([ // axios triggered errors
|
|
248
|
+
// ['response', 'data', 'error'],
|
|
249
|
+
// ]);
|
|
250
|
+
// this.errorPathsAxiosAny = () => ([]); // 200's that should be errors
|
|
246
251
|
}
|
|
247
252
|
|
|
248
253
|
async validateToken({
|
|
@@ -518,7 +523,7 @@ class Plugin {
|
|
|
518
523
|
const model = {
|
|
519
524
|
OptionInfoRequest: {
|
|
520
525
|
Opt: optionId,
|
|
521
|
-
Info: '
|
|
526
|
+
Info: 'S',
|
|
522
527
|
DateFrom: startDate,
|
|
523
528
|
DateTo: startDate,
|
|
524
529
|
RoomConfigs: this.getPaxConfigs(paxConfigs, true),
|
|
@@ -532,47 +537,84 @@ class Plugin {
|
|
|
532
537
|
axios,
|
|
533
538
|
xmlOptions: hostConnectXmlOptions,
|
|
534
539
|
});
|
|
535
|
-
const optAvail = R.path(['OptionInfoReply', 'Option', 'OptAvail'], replyObj);
|
|
536
540
|
/*
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
541
|
+
If not rates, optionInfoReply is null, meaning it's not bookable
|
|
542
|
+
otherwise, example data:
|
|
543
|
+
{
|
|
544
|
+
optionInfoReply: {
|
|
545
|
+
Option: {
|
|
546
|
+
Opt: 'LHRTRDAVIDSHABTVC',
|
|
547
|
+
OptStayResults: {
|
|
548
|
+
AgentPrice: '51175',
|
|
549
|
+
Availability: 'RQ',
|
|
550
|
+
CancelHours: '96',
|
|
551
|
+
CommissionPercent: '0.00',
|
|
552
|
+
Currency: 'GBP',
|
|
553
|
+
PeriodValueAdds: {
|
|
554
|
+
PeriodValueAdd: {
|
|
555
|
+
DateFrom: '2024-08-10',
|
|
556
|
+
DateTo: '2024-08-10',
|
|
557
|
+
RateName: 'Std-Mon Sun',
|
|
558
|
+
RateText: 'Std'
|
|
559
|
+
}
|
|
560
|
+
},
|
|
561
|
+
RateId: 'Default',
|
|
562
|
+
RateName: 'Std-Mon Sun',
|
|
563
|
+
RateText: 'Std',
|
|
564
|
+
SaleFrom: '2023-12-20',
|
|
565
|
+
TotalPrice: '51175'
|
|
566
|
+
},
|
|
567
|
+
OptionNumber: '70461'
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
}
|
|
548
571
|
*/
|
|
549
|
-
|
|
550
|
-
return {
|
|
551
|
-
available: false,
|
|
552
|
-
};
|
|
553
|
-
}
|
|
554
|
-
if (optAvail === -2) {
|
|
555
|
-
return {
|
|
556
|
-
available: true,
|
|
557
|
-
type: 'free sell',
|
|
558
|
-
};
|
|
559
|
-
}
|
|
560
|
-
if (optAvail === -3) {
|
|
561
|
-
return {
|
|
562
|
-
available: true,
|
|
563
|
-
type: 'on request',
|
|
564
|
-
};
|
|
565
|
-
}
|
|
566
|
-
if (optAvail > 0) {
|
|
567
|
-
return {
|
|
568
|
-
available: true,
|
|
569
|
-
type: 'inventory',
|
|
570
|
-
quantity: optAvail,
|
|
571
|
-
};
|
|
572
|
-
}
|
|
572
|
+
const optionInfoReply = R.path(['OptionInfoReply'], replyObj);
|
|
573
573
|
return {
|
|
574
|
-
|
|
574
|
+
bookable: Boolean(optionInfoReply),
|
|
575
575
|
};
|
|
576
|
+
// THE BELOW CODE is for A check, might still need it on user's future request
|
|
577
|
+
// const optAvail = parseInt(R.pathOr('-4', ['OptionInfoReply', 'Option', 'OptAvail'], replyObj), 10);
|
|
578
|
+
// /*
|
|
579
|
+
// FROM TP DOCS:
|
|
580
|
+
// Each integer in the list gives the availability for one of the days in the range requested,
|
|
581
|
+
// from the start date through to the end date. The integer values are to be interpreted as
|
|
582
|
+
// follows:
|
|
583
|
+
// Greater than 0 means that inventory is available, with the integer specifying the
|
|
584
|
+
// number of units available. For options with a service type of Y , the inventory is in
|
|
585
|
+
// units of rooms. For other service types, the inventory is in units of pax.
|
|
586
|
+
// -1 Not available.
|
|
587
|
+
// -2 Available on free sell.
|
|
588
|
+
// -3 Available on request.
|
|
589
|
+
// Note: A return value of 0 or something less than -3 is impossible.
|
|
590
|
+
// */
|
|
591
|
+
// if (optAvail === -1) {
|
|
592
|
+
// return {
|
|
593
|
+
// available: false,
|
|
594
|
+
// };
|
|
595
|
+
// }
|
|
596
|
+
// if (optAvail === -2) {
|
|
597
|
+
// return {
|
|
598
|
+
// available: true,
|
|
599
|
+
// type: 'free sell',
|
|
600
|
+
// };
|
|
601
|
+
// }
|
|
602
|
+
// if (optAvail === -3) {
|
|
603
|
+
// return {
|
|
604
|
+
// available: true,
|
|
605
|
+
// type: 'on request',
|
|
606
|
+
// };
|
|
607
|
+
// }
|
|
608
|
+
// if (optAvail > 0) {
|
|
609
|
+
// return {
|
|
610
|
+
// available: true,
|
|
611
|
+
// type: 'inventory',
|
|
612
|
+
// quantity: optAvail,
|
|
613
|
+
// };
|
|
614
|
+
// }
|
|
615
|
+
// return {
|
|
616
|
+
// available: false,
|
|
617
|
+
// };
|
|
576
618
|
}
|
|
577
619
|
|
|
578
620
|
async searchQuote({
|
|
@@ -625,26 +667,26 @@ class Plugin {
|
|
|
625
667
|
...(rateId ? {
|
|
626
668
|
RateId: rateId,
|
|
627
669
|
} : {}),
|
|
628
|
-
...(puInfo ? {
|
|
670
|
+
...(puInfo && (puInfo.time || puInfo.location || puInfo.flightDetails) ? {
|
|
629
671
|
...(puInfo.time && puInfo.time.replace(/\D/g, '') ? {
|
|
630
672
|
puTime: puInfo.time.replace(/\D/g, ''),
|
|
631
673
|
} : {}),
|
|
632
|
-
puRemark: this.escapeInvalidXmlChars(`Time: ${puInfo.time || 'NA'}
|
|
633
|
-
Location: ${puInfo.location || 'NA'}
|
|
634
|
-
Flight: ${puInfo.flightDetails || 'NA'}
|
|
674
|
+
puRemark: this.escapeInvalidXmlChars(`${puInfo.time ? `Time: ${puInfo.time || 'NA'},` : ''}
|
|
675
|
+
${puInfo.location ? `Location: ${puInfo.location || 'NA'},` : ''}
|
|
676
|
+
${puInfo.flightDetails ? `Flight: ${puInfo.flightDetails || 'NA'},` : ''}
|
|
635
677
|
`),
|
|
636
678
|
} : {}),
|
|
637
|
-
...(doInfo ? {
|
|
679
|
+
...(doInfo && (doInfo.time || doInfo.location || doInfo.flightDetails) ? {
|
|
638
680
|
// only get numbers from doInfo.time
|
|
639
681
|
...(doInfo.time && doInfo.time.replace(/\D/g, '') ? {
|
|
640
682
|
doTime: doInfo.time.replace(/\D/g, ''),
|
|
641
683
|
} : {}),
|
|
642
|
-
doRemark: this.escapeInvalidXmlChars(`Time: ${doInfo.time || 'NA'}
|
|
643
|
-
Location: ${doInfo.location || 'NA'}
|
|
644
|
-
Flight: ${doInfo.flightDetails || 'NA'}
|
|
684
|
+
doRemark: this.escapeInvalidXmlChars(`${doInfo.time ? `Time: ${doInfo.time || 'NA'},` : ''}
|
|
685
|
+
${doInfo.location ? `Location: ${doInfo.location || 'NA'},` : ''}
|
|
686
|
+
${doInfo.flightDetails ? `Flight: ${doInfo.flightDetails || 'NA'},` : ''}
|
|
645
687
|
`),
|
|
646
688
|
} : {}),
|
|
647
|
-
Remarks: this.escapeInvalidXmlChars(`${notes || ''} ${extraText ? `\nExtras: ${extraText}` : ''}`),
|
|
689
|
+
Remarks: this.escapeInvalidXmlChars(`${notes || ''} ${extraText ? `\nExtras: ${extraText}` : ''}`).slice(0, 240),
|
|
648
690
|
Opt: optionId,
|
|
649
691
|
DateFrom: startDate,
|
|
650
692
|
RateId: 'Default',
|
|
@@ -722,6 +764,10 @@ class Plugin {
|
|
|
722
764
|
try {
|
|
723
765
|
reply = await this.callTourplan(getPayload('ListBookingsRequest', { [key]: bookingId }));
|
|
724
766
|
} catch (err) {
|
|
767
|
+
if (err.includes && err.includes('Request failed with status code')) {
|
|
768
|
+
throw Error(err);
|
|
769
|
+
}
|
|
770
|
+
// if it's not server error, we just considered as no booking is found
|
|
725
771
|
console.log('error in searchBooking', err);
|
|
726
772
|
reply = { ListBookingsReply: { BookingHeaders: { BookingHeader: [] } } };
|
|
727
773
|
}
|