ti2-ventrata 1.0.14 → 1.0.16
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 +27 -7
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -102,6 +102,7 @@ const capitalize = sParam => {
|
|
|
102
102
|
const unitMap = {
|
|
103
103
|
unitId: R.path(['id']),
|
|
104
104
|
unitName: R.path(['title']),
|
|
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
|
-
|
|
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
|
-
...
|
|
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,
|
|
@@ -241,22 +247,24 @@ class Plugin {
|
|
|
241
247
|
endpoint,
|
|
242
248
|
octoEnv,
|
|
243
249
|
acceptLanguage,
|
|
250
|
+
resellerId,
|
|
244
251
|
},
|
|
245
252
|
}) {
|
|
246
|
-
const url = `${endpoint || this.endpoint}/
|
|
253
|
+
const url = `${endpoint || this.endpoint}/whoami?token=${apiKey}`;
|
|
247
254
|
const headers = getHeaders({
|
|
248
255
|
apiKey,
|
|
249
256
|
endpoint,
|
|
250
257
|
octoEnv,
|
|
251
258
|
acceptLanguage,
|
|
259
|
+
resellerId,
|
|
252
260
|
});
|
|
253
261
|
try {
|
|
254
|
-
const
|
|
262
|
+
const connectionId = R.path(['data', 'connection', 'id'], await axios({
|
|
255
263
|
method: 'get',
|
|
256
264
|
url,
|
|
257
265
|
headers,
|
|
258
266
|
}));
|
|
259
|
-
return
|
|
267
|
+
return /[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/.test(connectionId);
|
|
260
268
|
} catch (err) {
|
|
261
269
|
return false;
|
|
262
270
|
}
|
|
@@ -268,6 +276,7 @@ class Plugin {
|
|
|
268
276
|
endpoint,
|
|
269
277
|
octoEnv,
|
|
270
278
|
acceptLanguage,
|
|
279
|
+
resellerId,
|
|
271
280
|
},
|
|
272
281
|
payload,
|
|
273
282
|
}) {
|
|
@@ -282,6 +291,7 @@ class Plugin {
|
|
|
282
291
|
endpoint,
|
|
283
292
|
octoEnv,
|
|
284
293
|
acceptLanguage,
|
|
294
|
+
resellerId,
|
|
285
295
|
});
|
|
286
296
|
let results = R.pathOr([], ['data'], await axios({
|
|
287
297
|
method: 'get',
|
|
@@ -313,6 +323,7 @@ class Plugin {
|
|
|
313
323
|
endpoint,
|
|
314
324
|
octoEnv,
|
|
315
325
|
acceptLanguage,
|
|
326
|
+
resellerId,
|
|
316
327
|
},
|
|
317
328
|
payload: {
|
|
318
329
|
productIds,
|
|
@@ -333,6 +344,7 @@ class Plugin {
|
|
|
333
344
|
endpoint,
|
|
334
345
|
octoEnv,
|
|
335
346
|
acceptLanguage,
|
|
347
|
+
resellerId,
|
|
336
348
|
});
|
|
337
349
|
const url = `${endpoint || this.endpoint}/products/${productId}`;
|
|
338
350
|
return axios({
|
|
@@ -358,6 +370,7 @@ class Plugin {
|
|
|
358
370
|
endpoint,
|
|
359
371
|
octoEnv,
|
|
360
372
|
acceptLanguage,
|
|
373
|
+
resellerId,
|
|
361
374
|
},
|
|
362
375
|
token,
|
|
363
376
|
payload: {
|
|
@@ -400,6 +413,7 @@ class Plugin {
|
|
|
400
413
|
endpoint,
|
|
401
414
|
octoEnv,
|
|
402
415
|
acceptLanguage,
|
|
416
|
+
resellerId,
|
|
403
417
|
});
|
|
404
418
|
const url = `${endpoint || this.endpoint}/availability`;
|
|
405
419
|
let availability = (
|
|
@@ -449,6 +463,7 @@ class Plugin {
|
|
|
449
463
|
endpoint,
|
|
450
464
|
octoEnv,
|
|
451
465
|
acceptLanguage,
|
|
466
|
+
resellerId,
|
|
452
467
|
},
|
|
453
468
|
token,
|
|
454
469
|
payload: {
|
|
@@ -491,6 +506,7 @@ class Plugin {
|
|
|
491
506
|
endpoint,
|
|
492
507
|
octoEnv,
|
|
493
508
|
acceptLanguage,
|
|
509
|
+
resellerId,
|
|
494
510
|
});
|
|
495
511
|
const url = `${endpoint || this.endpoint}/availability/calendar`;
|
|
496
512
|
let availability = (
|
|
@@ -528,13 +544,13 @@ class Plugin {
|
|
|
528
544
|
endpoint,
|
|
529
545
|
octoEnv,
|
|
530
546
|
acceptLanguage,
|
|
547
|
+
resellerId,
|
|
531
548
|
},
|
|
532
549
|
payload: {
|
|
533
550
|
availabilityKey,
|
|
534
551
|
holder,
|
|
535
552
|
notes,
|
|
536
553
|
reference,
|
|
537
|
-
referrer,
|
|
538
554
|
settlementMethod,
|
|
539
555
|
},
|
|
540
556
|
}) {
|
|
@@ -547,7 +563,7 @@ class Plugin {
|
|
|
547
563
|
endpoint,
|
|
548
564
|
octoEnv,
|
|
549
565
|
acceptLanguage,
|
|
550
|
-
|
|
566
|
+
resellerId,
|
|
551
567
|
});
|
|
552
568
|
let url = `${endpoint || this.endpoint}/bookings`;
|
|
553
569
|
let data = await jwt.verify(availabilityKey, this.jwtKey);
|
|
@@ -584,6 +600,7 @@ class Plugin {
|
|
|
584
600
|
endpoint,
|
|
585
601
|
octoEnv,
|
|
586
602
|
acceptLanguage,
|
|
603
|
+
resellerId,
|
|
587
604
|
},
|
|
588
605
|
payload: {
|
|
589
606
|
bookingId,
|
|
@@ -597,6 +614,7 @@ class Plugin {
|
|
|
597
614
|
endpoint,
|
|
598
615
|
octoEnv,
|
|
599
616
|
acceptLanguage,
|
|
617
|
+
resellerId,
|
|
600
618
|
});
|
|
601
619
|
const url = `${endpoint || this.endpoint}/bookings/${bookingId || id}`;
|
|
602
620
|
const booking = R.path(['data'], await axios({
|
|
@@ -614,6 +632,7 @@ class Plugin {
|
|
|
614
632
|
endpoint,
|
|
615
633
|
octoEnv,
|
|
616
634
|
acceptLanguage,
|
|
635
|
+
resellerId,
|
|
617
636
|
},
|
|
618
637
|
payload: {
|
|
619
638
|
bookingId,
|
|
@@ -638,6 +657,7 @@ class Plugin {
|
|
|
638
657
|
endpoint,
|
|
639
658
|
octoEnv,
|
|
640
659
|
acceptLanguage,
|
|
660
|
+
resellerId,
|
|
641
661
|
});
|
|
642
662
|
const searchByUrl = async url => {
|
|
643
663
|
try {
|