ti2-tourplan 1.0.46 → 1.0.49
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 +38 -12
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -187,9 +187,15 @@ class Plugin {
|
|
|
187
187
|
return R.path(['Reply'], replyObj);
|
|
188
188
|
};
|
|
189
189
|
|
|
190
|
-
this.
|
|
190
|
+
this.getRoomConfigs = (paxConfigs, noPaxList) => {
|
|
191
|
+
// There should be only 1 RoomConfigs for AddServiceRequest
|
|
192
|
+
let RoomConfigs = {};
|
|
193
|
+
// add one RoomConfig for each room required (i.e. one for each PaxConfig)
|
|
194
|
+
RoomConfigs.RoomConfig = [];
|
|
195
|
+
let indexRoomConfig = 0;
|
|
191
196
|
paxConfigs.map(({ roomType, passengers = [] }) => {
|
|
192
|
-
const
|
|
197
|
+
const EachRoomConfig = passengers.reduce((acc, p) => {
|
|
198
|
+
console.log(JSON.stringify(p));
|
|
193
199
|
if (p.passengerType === 'Adult') {
|
|
194
200
|
acc.Adults += 1;
|
|
195
201
|
}
|
|
@@ -213,13 +219,13 @@ class Plugin {
|
|
|
213
219
|
Quad: 'QD',
|
|
214
220
|
Other: 'OT',
|
|
215
221
|
})[roomType];
|
|
216
|
-
if (RoomType)
|
|
222
|
+
if (RoomType) EachRoomConfig.RoomType = RoomType;
|
|
217
223
|
if (passengers && passengers.length && !noPaxList) {
|
|
218
|
-
// There should be only 1 PaxList inside each
|
|
219
|
-
|
|
224
|
+
// There should be only 1 PaxList inside each EachRoomConfig
|
|
225
|
+
EachRoomConfig.PaxList = {};
|
|
220
226
|
// Inside PaxList, there should be 1 PaxDetails for each passenger (Pax)
|
|
221
|
-
|
|
222
|
-
passengers.forEach((p,
|
|
227
|
+
EachRoomConfig.PaxList.PaxDetails = [];
|
|
228
|
+
passengers.forEach((p, indexEachPax) => {
|
|
223
229
|
const EachPaxDetails = {
|
|
224
230
|
Forename: this.escapeInvalidXmlChars(p.firstName),
|
|
225
231
|
Surname: this.escapeInvalidXmlChars(p.lastName),
|
|
@@ -236,11 +242,13 @@ class Plugin {
|
|
|
236
242
|
EachPaxDetails.Age = p.age;
|
|
237
243
|
}
|
|
238
244
|
}
|
|
239
|
-
|
|
245
|
+
EachRoomConfig.PaxList.PaxDetails[indexEachPax] = EachPaxDetails;
|
|
240
246
|
});
|
|
241
247
|
}
|
|
242
|
-
|
|
248
|
+
RoomConfigs.RoomConfig[indexRoomConfig++] = EachRoomConfig
|
|
243
249
|
});
|
|
250
|
+
return RoomConfigs;
|
|
251
|
+
};
|
|
244
252
|
this.escapeInvalidXmlChars = str => {
|
|
245
253
|
if (!str) return '';
|
|
246
254
|
const convertAccentedChars = s => {
|
|
@@ -466,9 +474,13 @@ class Plugin {
|
|
|
466
474
|
const products = R.call(R.compose(
|
|
467
475
|
R.map(optionsGroupedBySupplierId => {
|
|
468
476
|
const OptGeneral = R.pathOr({}, [0, 'OptGeneral'], optionsGroupedBySupplierId);
|
|
477
|
+
let supplierName = R.path(['SupplierName'], OptGeneral);
|
|
478
|
+
if (R.path(['SupplierName'], OptGeneral).toLocaleLowerCase() === 'transfers') {
|
|
479
|
+
supplierName = `${R.path(['VoucherName'], OptGeneral)} (${R.path(['SupplierName'], OptGeneral)})`;
|
|
480
|
+
}
|
|
469
481
|
const supplierData = {
|
|
470
482
|
supplierId: R.path(['SupplierId'], OptGeneral),
|
|
471
|
-
supplierName:
|
|
483
|
+
supplierName: supplierName,
|
|
472
484
|
supplierAddress: `${R.pathOr('', ['Address1'], OptGeneral)}, ${R.pathOr('', ['Address2'], OptGeneral)}, ${R.pathOr('', ['Address3'], OptGeneral)}, ${R.pathOr('', ['Address4'], OptGeneral)}, ${R.pathOr('', ['Address5'], OptGeneral)}`,
|
|
473
485
|
serviceTypes: R.uniq(optionsGroupedBySupplierId.map(R.path(['OptGeneral', 'ButtonName']))),
|
|
474
486
|
};
|
|
@@ -546,7 +558,7 @@ class Plugin {
|
|
|
546
558
|
if (isNaN(num) || num < 1) return 1;
|
|
547
559
|
return num;
|
|
548
560
|
})(),
|
|
549
|
-
RoomConfigs: this.
|
|
561
|
+
RoomConfigs: this.getRoomConfigs(paxConfigs, true),
|
|
550
562
|
AgentID: hostConnectAgentID,
|
|
551
563
|
Password: hostConnectAgentPassword,
|
|
552
564
|
},
|
|
@@ -714,7 +726,7 @@ class Plugin {
|
|
|
714
726
|
return num;
|
|
715
727
|
})(),
|
|
716
728
|
AgentRef: reference,
|
|
717
|
-
RoomConfigs: this.
|
|
729
|
+
RoomConfigs: this.getRoomConfigs(paxConfigs),
|
|
718
730
|
},
|
|
719
731
|
};
|
|
720
732
|
const replyObj = await this.callTourplan({
|
|
@@ -801,6 +813,20 @@ class Plugin {
|
|
|
801
813
|
console.log('error in searchBooking', err);
|
|
802
814
|
reply = { ListBookingsReply: { BookingHeaders: { BookingHeader: [] } } };
|
|
803
815
|
}
|
|
816
|
+
|
|
817
|
+
// {"ListBookingsReply":
|
|
818
|
+
// {"BookingHeaders":
|
|
819
|
+
// {"BookingHeader":[
|
|
820
|
+
// {"AgentRef":"2399181","BookingId":"314164","BookingStatus":"Quotation","BookingType":"F",
|
|
821
|
+
// "Consult":null,"Currency":"GBP","EnteredDate":"2024-05-23","IsInternetBooking":"Y",
|
|
822
|
+
// "Name":"Mr. Robert Slavonia x2 2399181","QB":"Q","Ref":"ALFI393309","TotalPrice":"583143",
|
|
823
|
+
// "TravelDate":"2024-07-09"},{"AgentRef":"666666/1","BookingId":"315357",
|
|
824
|
+
// "BookingStatus":"Quotation","BookingType":"F","Consult":null,"Currency":"GBP",
|
|
825
|
+
// "EnteredDate":"2024-06-04","IsInternetBooking":"Y","Name":"Robert Guerrerio x3 2413898",
|
|
826
|
+
// "QB":"Q","Ref":"ALFI393503","TotalPrice":"2309452","TravelDate":"2024-08-31"
|
|
827
|
+
// }
|
|
828
|
+
// ]}
|
|
829
|
+
// }}
|
|
804
830
|
return reply;
|
|
805
831
|
})
|
|
806
832
|
: [this.callTourplan(listBookingPayload)];
|