ti2-tourplan 1.0.45 → 1.0.47

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 +24 -14
  2. 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.getPaxConfigs = (paxConfigs, noPaxList) =>
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 RoomConfig = passengers.reduce((acc, p) => {
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,10 +219,14 @@ class Plugin {
213
219
  Quad: 'QD',
214
220
  Other: 'OT',
215
221
  })[roomType];
216
- if (RoomType) RoomConfig.RoomType = RoomType;
222
+ if (RoomType) EachRoomConfig.RoomType = RoomType;
217
223
  if (passengers && passengers.length && !noPaxList) {
218
- RoomConfig.PaxList = passengers.map(p => {
219
- const PaxDetails = {
224
+ // There should be only 1 PaxList inside each EachRoomConfig
225
+ EachRoomConfig.PaxList = {};
226
+ // Inside PaxList, there should be 1 PaxDetails for each passenger (Pax)
227
+ EachRoomConfig.PaxList.PaxDetails = [];
228
+ passengers.forEach((p, indexEachPax) => {
229
+ const EachPaxDetails = {
220
230
  Forename: this.escapeInvalidXmlChars(p.firstName),
221
231
  Surname: this.escapeInvalidXmlChars(p.lastName),
222
232
  PaxType: {
@@ -225,20 +235,20 @@ class Plugin {
225
235
  Infant: 'I',
226
236
  }[p.passengerType] || 'A',
227
237
  };
228
- if (p.salutation) PaxDetails.Title = this.escapeInvalidXmlChars(p.salutation);
229
- if (p.dob) PaxDetails.DateOfBirth = p.dob;
238
+ if (p.salutation) EachPaxDetails.Title = this.escapeInvalidXmlChars(p.salutation);
239
+ if (p.dob) EachPaxDetails.DateOfBirth = p.dob;
230
240
  if (!R.isNil(p.age) && !isNaN(p.age)) {
231
241
  if (!(p.passengerType === 'Adult' && p.age === 0)) {
232
- PaxDetails.Age = p.age;
242
+ EachPaxDetails.Age = p.age;
233
243
  }
234
244
  }
235
- return {
236
- PaxDetails,
237
- };
245
+ EachRoomConfig.PaxList.PaxDetails[indexEachPax] = EachPaxDetails;
238
246
  });
239
247
  }
240
- return { RoomConfig };
248
+ RoomConfigs.RoomConfig[indexRoomConfig++] = EachRoomConfig
241
249
  });
250
+ return RoomConfigs;
251
+ };
242
252
  this.escapeInvalidXmlChars = str => {
243
253
  if (!str) return '';
244
254
  const convertAccentedChars = s => {
@@ -544,7 +554,7 @@ class Plugin {
544
554
  if (isNaN(num) || num < 1) return 1;
545
555
  return num;
546
556
  })(),
547
- RoomConfigs: this.getPaxConfigs(paxConfigs, true),
557
+ RoomConfigs: this.getRoomConfigs(paxConfigs, true),
548
558
  AgentID: hostConnectAgentID,
549
559
  Password: hostConnectAgentPassword,
550
560
  },
@@ -712,7 +722,7 @@ class Plugin {
712
722
  return num;
713
723
  })(),
714
724
  AgentRef: reference,
715
- RoomConfigs: this.getPaxConfigs(paxConfigs),
725
+ RoomConfigs: this.getRoomConfigs(paxConfigs),
716
726
  },
717
727
  };
718
728
  const replyObj = await this.callTourplan({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ti2-tourplan",
3
- "version": "1.0.45",
3
+ "version": "1.0.47",
4
4
  "description": "Tourplan's TI2 Plugin",
5
5
  "main": "index.js",
6
6
  "scripts": {