ti2-ventrata 1.0.15 → 1.0.17

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 +32 -7
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -40,7 +40,7 @@ const doMapCurry = mapObj => item => doMap(item, mapObj);
40
40
 
41
41
  const productMapIn = {
42
42
  productId: R.path(['id']),
43
- productName: R.path(['title']),
43
+ productName: o => R.path(['title'], o) || R.prop('internalName', o),
44
44
  availableCurrencies: R.path(['availableCurrencies']),
45
45
  defaultCurrency: R.path(['defaultCurrency']),
46
46
  options: e => R.pathOr(undefined, ['options'], e).map(option => doMap(option, optionMapIn, ['id', 'title'])),
@@ -48,7 +48,7 @@ const productMapIn = {
48
48
 
49
49
  const optionMapIn = {
50
50
  optionId: R.path(['id']),
51
- optionName: R.path(['title']),
51
+ optionName: o => R.path(['title'], o) || R.prop('internalName', o),
52
52
  units: option => R.pathOr(undefined, ['units'], option).map(unit => doMap(unit, unitMap)),
53
53
  };
54
54
 
@@ -101,7 +101,8 @@ const capitalize = sParam => {
101
101
 
102
102
  const unitMap = {
103
103
  unitId: R.path(['id']),
104
- unitName: R.path(['title']),
104
+ unitName: o => R.path(['title'], o) || R.prop('internalName', o),
105
+ type: R.path(['type']),
105
106
  subtitle: R.path(['subtitle']),
106
107
  restrictions: R.path(['restrictions']),
107
108
  pricing: root => R.path(['pricing'], root) || R.path(['pricingFrom'], root),
@@ -193,13 +194,13 @@ const getHeaders = ({
193
194
  apiKey,
194
195
  acceptLanguage,
195
196
  octoEnv,
196
- referrer,
197
+ resellerId,
197
198
  }) => ({
198
199
  Authorization: `Bearer ${apiKey}`,
199
200
  ...octoEnv ? { 'Octo-Env': octoEnv } : {},
200
201
  ...acceptLanguage ? { 'Accept-Language': acceptLanguage } : {},
201
202
  'Content-Type': 'application/json',
202
- ...referrer ? { Referer: referrer } : {},
203
+ ...resellerId ? { Referer: resellerId } : {},
203
204
  });
204
205
 
205
206
  class Plugin {
@@ -213,6 +214,11 @@ class Plugin {
213
214
  regExp: /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,
214
215
  description: 'the Api Key provided from Ventrata, should be in uuid format',
215
216
  },
217
+ resellerId: {
218
+ type: 'text',
219
+ regExp: /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,
220
+ description: 'the Reseller Id provided from Ventrata, should be in uuid format',
221
+ },
216
222
  endpoint: {
217
223
  type: 'text',
218
224
  regExp: /^(?!mailto:)(?:(?:http|https|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?:(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[0-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))|localhost)(?::\d{2,5})?(?:(\/|\?|#)[^\s]*)?$/i,
@@ -239,11 +245,18 @@ class Plugin {
239
245
  token: {
240
246
  apiKey,
241
247
  endpoint,
248
+ octoEnv,
249
+ acceptLanguage,
250
+ resellerId,
242
251
  },
243
252
  }) {
244
253
  const url = `${endpoint || this.endpoint}/whoami?token=${apiKey}`;
245
254
  const headers = getHeaders({
246
255
  apiKey,
256
+ endpoint,
257
+ octoEnv,
258
+ acceptLanguage,
259
+ resellerId,
247
260
  });
248
261
  try {
249
262
  const connectionId = R.path(['data', 'connection', 'id'], await axios({
@@ -263,6 +276,7 @@ class Plugin {
263
276
  endpoint,
264
277
  octoEnv,
265
278
  acceptLanguage,
279
+ resellerId,
266
280
  },
267
281
  payload,
268
282
  }) {
@@ -277,6 +291,7 @@ class Plugin {
277
291
  endpoint,
278
292
  octoEnv,
279
293
  acceptLanguage,
294
+ resellerId,
280
295
  });
281
296
  let results = R.pathOr([], ['data'], await axios({
282
297
  method: 'get',
@@ -308,6 +323,7 @@ class Plugin {
308
323
  endpoint,
309
324
  octoEnv,
310
325
  acceptLanguage,
326
+ resellerId,
311
327
  },
312
328
  payload: {
313
329
  productIds,
@@ -328,6 +344,7 @@ class Plugin {
328
344
  endpoint,
329
345
  octoEnv,
330
346
  acceptLanguage,
347
+ resellerId,
331
348
  });
332
349
  const url = `${endpoint || this.endpoint}/products/${productId}`;
333
350
  return axios({
@@ -353,6 +370,7 @@ class Plugin {
353
370
  endpoint,
354
371
  octoEnv,
355
372
  acceptLanguage,
373
+ resellerId,
356
374
  },
357
375
  token,
358
376
  payload: {
@@ -395,6 +413,7 @@ class Plugin {
395
413
  endpoint,
396
414
  octoEnv,
397
415
  acceptLanguage,
416
+ resellerId,
398
417
  });
399
418
  const url = `${endpoint || this.endpoint}/availability`;
400
419
  let availability = (
@@ -444,6 +463,7 @@ class Plugin {
444
463
  endpoint,
445
464
  octoEnv,
446
465
  acceptLanguage,
466
+ resellerId,
447
467
  },
448
468
  token,
449
469
  payload: {
@@ -486,6 +506,7 @@ class Plugin {
486
506
  endpoint,
487
507
  octoEnv,
488
508
  acceptLanguage,
509
+ resellerId,
489
510
  });
490
511
  const url = `${endpoint || this.endpoint}/availability/calendar`;
491
512
  let availability = (
@@ -523,13 +544,13 @@ class Plugin {
523
544
  endpoint,
524
545
  octoEnv,
525
546
  acceptLanguage,
547
+ resellerId,
526
548
  },
527
549
  payload: {
528
550
  availabilityKey,
529
551
  holder,
530
552
  notes,
531
553
  reference,
532
- referrer,
533
554
  settlementMethod,
534
555
  },
535
556
  }) {
@@ -542,7 +563,7 @@ class Plugin {
542
563
  endpoint,
543
564
  octoEnv,
544
565
  acceptLanguage,
545
- referrer,
566
+ resellerId,
546
567
  });
547
568
  let url = `${endpoint || this.endpoint}/bookings`;
548
569
  let data = await jwt.verify(availabilityKey, this.jwtKey);
@@ -579,6 +600,7 @@ class Plugin {
579
600
  endpoint,
580
601
  octoEnv,
581
602
  acceptLanguage,
603
+ resellerId,
582
604
  },
583
605
  payload: {
584
606
  bookingId,
@@ -592,6 +614,7 @@ class Plugin {
592
614
  endpoint,
593
615
  octoEnv,
594
616
  acceptLanguage,
617
+ resellerId,
595
618
  });
596
619
  const url = `${endpoint || this.endpoint}/bookings/${bookingId || id}`;
597
620
  const booking = R.path(['data'], await axios({
@@ -609,6 +632,7 @@ class Plugin {
609
632
  endpoint,
610
633
  octoEnv,
611
634
  acceptLanguage,
635
+ resellerId,
612
636
  },
613
637
  payload: {
614
638
  bookingId,
@@ -633,6 +657,7 @@ class Plugin {
633
657
  endpoint,
634
658
  octoEnv,
635
659
  acceptLanguage,
660
+ resellerId,
636
661
  });
637
662
  const searchByUrl = async url => {
638
663
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ti2-ventrata",
3
- "version": "1.0.15",
3
+ "version": "1.0.17",
4
4
  "description": "Ventrata's TI2 Plugin",
5
5
  "main": "index.js",
6
6
  "scripts": {