ti2-tourplan 1.0.26 → 1.0.28

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  const axiosRaw = require('axios');
2
- // const Promise = require('bluebird');
2
+ const Promise = require('bluebird');
3
3
  const R = require('ramda');
4
4
  const assert = require('assert');
5
5
  const moment = require('moment');
@@ -463,256 +463,6 @@ class Plugin {
463
463
  };
464
464
  }
465
465
 
466
- async getProductPackages() {
467
- return [
468
- {
469
- packageId: 'a1b2c3d4-e8e8-11ec-8fea-0242ac120002',
470
- packageName: "Afternoon at St Paul's Cathedral and Kensington Palace (half day)",
471
- items: [],
472
- },
473
- {
474
- packageId: 'a1b2c3d4-e8e8-11ec-8feb-0242ac120002',
475
- packageName: 'Beefeater Day Out',
476
- items: [],
477
- },
478
- {
479
- packageId: 'a1b2c3d4-e8e8-11ec-8fec-0242ac120002',
480
- packageName: 'Brighton and Hove tour',
481
- items: [],
482
- },
483
- {
484
- packageId: 'a1b2c3d4-e8e8-11ec-8fed-0242ac120002',
485
- packageName: 'Buckingham Palace & Kensington Palace (full day)',
486
- items: [],
487
- },
488
- {
489
- packageId: 'a1b2c3d4-e8e8-11ec-8fee-0242ac120002',
490
- packageName: 'Buckingham Palace and Hampton Court Palace (full day)',
491
- items: [],
492
- },
493
- {
494
- packageId: 'a1b2c3d4-e8e8-11ec-8fef-0242ac120002',
495
- packageName: 'Buckingham Palace and Windsor Castle (full day)',
496
- items: [],
497
- },
498
- {
499
- packageId: 'a1b2c3d4-e8e8-11ec-8ff0-0242ac120002',
500
- packageName: 'Canterbury & Dover day trip',
501
- items: [],
502
- },
503
- {
504
- packageId: 'a1b2c3d4-e8e8-11ec-8ff1-0242ac120002',
505
- packageName: 'Canterbury day trip',
506
- items: [],
507
- },
508
- {
509
- packageId: 'a1b2c3d4-e8e8-11ec-8ff2-0242ac120002',
510
- packageName: 'Churchill War Rooms and the Imperial War Museum',
511
- items: [],
512
- },
513
- {
514
- packageId: 'a1b2c3d4-e8e8-11ec-8ff3-0242ac120002',
515
- packageName: 'Churchill War Rooms, the Changing of the Guards & the Tower of London',
516
- items: [],
517
- },
518
- {
519
- packageId: 'a1b2c3d4-e8e8-11ec-8ff4-0242ac120002',
520
- packageName: "City walking tour, St Paul's Cathedral and theatre performance at the Globe",
521
- items: [],
522
- },
523
- {
524
- packageId: 'a1b2c3d4-e8e8-11ec-8ff5-0242ac120002',
525
- packageName: 'Downton Abbey day trip',
526
- items: [],
527
- },
528
- {
529
- packageId: 'a1b2c3d4-e8e8-11ec-8ff6-0242ac120002',
530
- packageName: "Guided tour of St Paul's Cathedral",
531
- items: [],
532
- },
533
- {
534
- packageId: 'a1b2c3d4-e8e8-11ec-8ff7-0242ac120002',
535
- packageName: 'Hampton Court Palace (half day)',
536
- items: [],
537
- },
538
- {
539
- packageId: 'a1b2c3d4-e8e8-11ec-8ff8-0242ac120002',
540
- packageName: 'Hampton Court Palace and Windsor Castle (full day)',
541
- items: [],
542
- },
543
- {
544
- packageId: 'a1b2c3d4-e8e8-11ec-8ff9-0242ac120002',
545
- packageName: 'Kensington Palace and the Tower of London (full day)',
546
- items: [
547
- {
548
- itemId: 'LONGUACLUXELONFDG',
549
- itemType: 'option',
550
- },
551
- {
552
- itemId: 'LONEFKENPALFIKENI',
553
- itemType: 'option',
554
- },
555
- {
556
- itemId: 'LONEFTOWLONFITOWL',
557
- itemType: 'option',
558
- },
559
- ],
560
- },
561
- {
562
- packageId: 'a1b2c3d4-e8e8-11ec-8ffa-0242ac120002',
563
- packageName: 'Kensington Palace and Westminster Abbey (half day)',
564
- items: [],
565
- },
566
- {
567
- packageId: 'a1b2c3d4-e8e8-11ec-8ffb-0242ac120002',
568
- packageName: "Late afternoon visit to St Paul's Cathedral",
569
- items: [],
570
- },
571
- {
572
- packageId: 'a1b2c3d4-e8e8-11ec-8ffc-0242ac120002',
573
- packageName: "St Paul's Cathedral & Kensington Palace (half day)",
574
- items: [],
575
- },
576
- {
577
- packageId: 'a1b2c3d4-e8e8-11ec-8ffd-0242ac120002',
578
- packageName: "St Paul's Cathedral and the Churchill War Rooms (half day)",
579
- items: [],
580
- },
581
- {
582
- packageId: 'a1b2c3d4-e8e8-11ec-8ffe-0242ac120002',
583
- packageName: "St Paul's Cathedral and Westminster Abbey (half day)",
584
- items: [
585
- {
586
- itemId: 'LONGUACLUXELONHDG',
587
- itemType: 'option',
588
- },
589
- {
590
- itemId: 'LONEFSTPCATFITSPC',
591
- itemType: 'option',
592
- },
593
- {
594
- itemId: 'LONSSGOLTOUGTWAP',
595
- itemType: 'option',
596
- },
597
- ],
598
- },
599
- {
600
- packageId: 'a1b2c3d4-e8e8-11ec-8fff-0242ac120002',
601
- packageName: "St Paul's Cathedral, Changing of the Guard and Tower of London (full day)",
602
- items: [
603
- {
604
- itemId: 'LONGUACLUXELONFDG',
605
- itemType: 'option',
606
- },
607
- {
608
- itemId: 'LONEFTOWLONFITOWL',
609
- itemType: 'option',
610
- },
611
- {
612
- itemId: 'LONEFGOLTOUGT105N',
613
- itemType: 'option',
614
- },
615
- ],
616
- },
617
- {
618
- packageId: 'a1b2c3d4-e8e8-11ec-9000-0242ac120002',
619
- packageName: "St Paul's Cathedral, Kensington Palace and Westminster Abbey (full day)",
620
- items: [],
621
- },
622
- {
623
- packageId: 'a1b2c3d4-e8e8-11ec-9001-0242ac120002',
624
- packageName: 'St Pauls and Tower of London',
625
- items: [],
626
- },
627
- {
628
- packageId: 'a1b2c3d4-e8e8-11ec-9002-0242ac120002',
629
- packageName: 'Stonehenge (Full Day from London)',
630
- items: [],
631
- },
632
- {
633
- packageId: 'a1b2c3d4-e8e8-11ec-9003-0242ac120002',
634
- packageName: 'Stonehenge, Lacock and Avebury (full day)',
635
- items: [],
636
- },
637
- {
638
- packageId: 'a1b2c3d4-e8e8-11ec-9004-0242ac120002',
639
- packageName: 'The White Cliffs of Dover, Dover Castle, & military tunnels (full day)',
640
- items: [],
641
- },
642
- {
643
- packageId: 'a1b2c3d4-e8e8-11ec-9005-0242ac120002',
644
- packageName: 'Tower of London by boat',
645
- items: [
646
- {
647
- itemId: 'LONGUACLUXELONHDG',
648
- itemType: 'option',
649
- },
650
- {
651
- itemId: 'LONSSTHACLISINLON',
652
- itemType: 'option',
653
- },
654
- {
655
- itemId: 'LONEFTOWLONFITOWL',
656
- itemType: 'option',
657
- },
658
- ],
659
- },
660
- {
661
- packageId: 'a1b2c3d4-e8e8-11ec-9006-0242ac120002',
662
- packageName: 'Warner Bros.- The Making of Harry Potter (non refundable)',
663
- items: [],
664
- },
665
- {
666
- packageId: 'a1b2c3d4-e8e8-11ec-9007-0242ac120002',
667
- packageName: 'Westminster Abbey and Buckingham Palace (half day)',
668
- items: [],
669
- },
670
- {
671
- packageId: 'a1b2c3d4-e8e8-11ec-9008-0242ac120002',
672
- packageName: 'Westminster Abbey and Changing of the Guard',
673
- items: [
674
- {
675
- itemId: 'LONGUACLUXELONHDG',
676
- itemType: 'option',
677
- },
678
- {
679
- itemId: 'LONEFWESABBWESABB',
680
- itemType: 'option',
681
- },
682
- ],
683
- },
684
- {
685
- packageId: 'a1b2c3d4-e8e8-11ec-9009-0242ac120002',
686
- packageName: 'Westminster Abbey and the Tower by boat (full day)',
687
- items: [],
688
- },
689
- {
690
- packageId: 'a1b2c3d4-e8e8-11ec-900a-0242ac120002',
691
- packageName: 'Westminster Abbey, Changing of the Guard & Kensington Palace (full day)',
692
- items: [],
693
- },
694
- {
695
- packageId: 'a1b2c3d4-e8e8-11ec-900b-0242ac120002',
696
- packageName: 'Westminster Abbey, Changing of the Guard and Buckingham Palace',
697
- items: [],
698
- },
699
- {
700
- packageId: 'a1b2c3d4-e8e8-11ec-900c-0242ac120002',
701
- packageName: 'Westminster and the Tower of London (half day)',
702
- items: [],
703
- },
704
- {
705
- packageId: 'a1b2c3d4-e8e8-11ec-900d-0242ac120002',
706
- packageName: 'Westminster, Changing of the Guard and the Tower of London (full day)',
707
- items: [],
708
- },
709
- {
710
- packageId: 'a1b2c3d4-e8e8-11ec-900e-0242ac120002',
711
- packageName: 'Windsor Castle (half day)',
712
- items: [],
713
- },
714
- ];
715
- }
716
466
 
717
467
  async searchQuote({
718
468
  axios,
@@ -780,7 +530,6 @@ class Plugin {
780
530
  axios,
781
531
  xmlOptions: hostConnectXmlOptions,
782
532
  });
783
- console.log('replyObj', replyObj);
784
533
  return {
785
534
  message: R.path(['AddServiceReply', 'Status'], replyObj)
786
535
  === 'NO' ? 'Service cannot be added to quote' : '',
@@ -808,6 +557,69 @@ class Plugin {
808
557
  customFields,
809
558
  };
810
559
  }
560
+
561
+ async searchBooking({
562
+ token: {
563
+ hostConnectAgentID,
564
+ hostConnectAgentPassword,
565
+ hostConnectEndpoint,
566
+ },
567
+ axios,
568
+ payload: {
569
+ purchaseDateStart,
570
+ purchaseDateEnd,
571
+ bookingId,
572
+ },
573
+ }) {
574
+ const getPayload = (RequestType, RequestInput) => ({
575
+ model: {
576
+ [RequestType]: {
577
+ AgentID: hostConnectAgentID,
578
+ Password: hostConnectAgentPassword,
579
+ ...RequestInput,
580
+ },
581
+ },
582
+ endpoint: hostConnectEndpoint,
583
+ axios,
584
+ xmlOptions: hostConnectXmlOptions,
585
+ });
586
+ const listBookingPayload = getPayload('ListBookingsRequest', {
587
+ EnteredDateFrom: purchaseDateStart || moment().subtract(6, 'month').format('YYYY-MM-DD'),
588
+ EnteredDateTo: purchaseDateEnd || moment().format('YYYY-MM-DD'),
589
+ });
590
+ const allSearches = bookingId
591
+ ? ['BookingId', 'Ref', 'AgentRef'].map(async key => {
592
+ let reply;
593
+ try {
594
+ reply = await this.callTourplan(getPayload('ListBookingsRequest', { [key]: bookingId }));
595
+ } catch (err) {
596
+ if (err.message.indexOf('not found') > -1) {
597
+ reply = { ListBookingsReply: { BookingHeaders: { BookingHeader: [] } } };
598
+ } else {
599
+ throw err;
600
+ }
601
+ }
602
+ return reply;
603
+ })
604
+ : [this.callTourplan(listBookingPayload)];
605
+ const replyObjs = await Promise.all(allSearches);
606
+ const bookingHeaders = R.flatten(replyObjs.map(o => R.pathOr([], ['ListBookingsReply', 'BookingHeaders', 'BookingHeader'], o)));
607
+ const bookings = await Promise.map(bookingHeaders, async bookingHeader => {
608
+ const getBookingPayload = getPayload('GetBookingRequest', {
609
+ BookingId: R.prop('BookingId', bookingHeader),
610
+ });
611
+ const bookingReply = await this.callTourplan(getBookingPayload);
612
+ const booking = R.path(['GetBookingReply'], bookingReply);
613
+ const Services = R.pathOr([], ['Services', 'Service'], booking);
614
+ return {
615
+ ...booking,
616
+ Services: Array.isArray(Services) ? Services : [Services],
617
+ };
618
+ }, { concurrency: 10 });
619
+ return {
620
+ bookings,
621
+ };
622
+ }
811
623
  }
812
624
 
813
625
  module.exports = Plugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ti2-tourplan",
3
- "version": "1.0.26",
3
+ "version": "1.0.28",
4
4
  "description": "Tourplan's TI2 Plugin",
5
5
  "main": "index.js",
6
6
  "scripts": {