ti2-tourplan 1.0.30 → 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.
- package/index.js +77 -60
- 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:
|
|
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({
|
|
@@ -548,49 +606,7 @@ class Plugin {
|
|
|
548
606
|
RateId: 'Default',
|
|
549
607
|
SCUqty: chargeUnitQuanity || 1,
|
|
550
608
|
AgentRef: reference,
|
|
551
|
-
RoomConfigs:
|
|
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
|
-
}),
|
|
609
|
+
RoomConfigs: this.getRoomConfigs(paxConfigs),
|
|
594
610
|
},
|
|
595
611
|
};
|
|
596
612
|
const replyObj = await this.callTourplan({
|
|
@@ -676,6 +692,7 @@ class Plugin {
|
|
|
676
692
|
const bookings = await Promise.map(bookingHeaders, async bookingHeader => {
|
|
677
693
|
const getBookingPayload = getPayload('GetBookingRequest', {
|
|
678
694
|
BookingId: R.prop('BookingId', bookingHeader),
|
|
695
|
+
ReturnAccountInfo: 'Y',
|
|
679
696
|
});
|
|
680
697
|
const bookingReply = await this.callTourplan(getBookingPayload);
|
|
681
698
|
const booking = R.path(['GetBookingReply'], bookingReply);
|