ti2-tourplan 1.0.46 → 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 +19 -11
  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,13 +219,13 @@ 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
- // There should be only 1 PaxList inside each RoomConfig
219
- RoomConfig.PaxList = {};
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
- RoomConfig.PaxList.PaxDetails = [];
222
- passengers.forEach((p, index) => {
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
- RoomConfig.PaxList.PaxDetails[index] = EachPaxDetails;
245
+ EachRoomConfig.PaxList.PaxDetails[indexEachPax] = EachPaxDetails;
240
246
  });
241
247
  }
242
- return { RoomConfig };
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 => {
@@ -546,7 +554,7 @@ class Plugin {
546
554
  if (isNaN(num) || num < 1) return 1;
547
555
  return num;
548
556
  })(),
549
- RoomConfigs: this.getPaxConfigs(paxConfigs, true),
557
+ RoomConfigs: this.getRoomConfigs(paxConfigs, true),
550
558
  AgentID: hostConnectAgentID,
551
559
  Password: hostConnectAgentPassword,
552
560
  },
@@ -714,7 +722,7 @@ class Plugin {
714
722
  return num;
715
723
  })(),
716
724
  AgentRef: reference,
717
- RoomConfigs: this.getPaxConfigs(paxConfigs),
725
+ RoomConfigs: this.getRoomConfigs(paxConfigs),
718
726
  },
719
727
  };
720
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.46",
3
+ "version": "1.0.47",
4
4
  "description": "Tourplan's TI2 Plugin",
5
5
  "main": "index.js",
6
6
  "scripts": {