ti2 1.0.71 → 1.0.73

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/api.yml CHANGED
@@ -284,6 +284,27 @@ components:
284
284
  type: object
285
285
  allOf: # Combines the BasicErrorModel and the inline model
286
286
  - $ref: '#/components/schemas/bookingDetail'
287
+ packageSearchQuery:
288
+ type: object
289
+ additionalProperties: true
290
+ description: Additional properties may be included
291
+ properties:
292
+ packageName:
293
+ type: string
294
+ required: false
295
+ description: Package Name wildcard match
296
+ example: '*bus*'
297
+ bookingsPackageSearchReturn:
298
+ type: object
299
+ additionalProperties: true
300
+ description: Additional properties may be included
301
+ properties:
302
+ packages:
303
+ type: array
304
+ required: false
305
+ description: Package Search Results
306
+ items:
307
+ type: object
287
308
  bookingsProductQuery:
288
309
  type: object
289
310
  additionalProperties: true
@@ -1481,6 +1502,85 @@ paths:
1481
1502
  application/json:
1482
1503
  schema:
1483
1504
  $ref: '#/components/schemas/cancellationReturn'
1505
+ /packages/{appKey}/{userId}/search:
1506
+ post:
1507
+ security:
1508
+ - bearerAuth: ['admin', 'user']
1509
+ tags:
1510
+ - bookings
1511
+ summary: Package Search
1512
+ operationId: getProductPackages
1513
+ parameters:
1514
+ - name: appKey
1515
+ in: path
1516
+ description: app to search the booking packages, defaults to first token
1517
+ required: true
1518
+ example: 'travelgate-hotelx'
1519
+ schema:
1520
+ type: string
1521
+ - name: userId
1522
+ in: path
1523
+ description: the user/company that the appKey belongs to
1524
+ required: true
1525
+ schema:
1526
+ type: string
1527
+ requestBody:
1528
+ description: Search query
1529
+ required: true
1530
+ content:
1531
+ application/json:
1532
+ schema:
1533
+ $ref: '#/components/schemas/packageSearchQuery'
1534
+ responses:
1535
+ '200':
1536
+ description: search results
1537
+ content:
1538
+ application/json:
1539
+ schema:
1540
+ $ref: '#/components/schemas/bookingsPackageSearchReturn'
1541
+ /packages/{appKey}/{userId}/{hint}/search:
1542
+ post:
1543
+ security:
1544
+ - bearerAuth: ['admin', 'user']
1545
+ tags:
1546
+ - bookings
1547
+ summary: Package Search using for an specific hint
1548
+ operationId: getProductPackages
1549
+ parameters:
1550
+ - name: appKey
1551
+ in: path
1552
+ description: app to search the booking packages, defaults to first token
1553
+ required: true
1554
+ example: 'travelgate-hotelx'
1555
+ schema:
1556
+ type: string
1557
+ - name: userId
1558
+ in: path
1559
+ description: the user/company that the appKey belongs to
1560
+ required: true
1561
+ schema:
1562
+ type: string
1563
+ - name: hint
1564
+ in: path
1565
+ description: a specific token hint to be used
1566
+ required: true
1567
+ example: 'travelgate-australia'
1568
+ schema:
1569
+ type: string
1570
+ requestBody:
1571
+ description: Search query
1572
+ required: true
1573
+ content:
1574
+ application/json:
1575
+ schema:
1576
+ $ref: '#/components/schemas/packageSearchQuery'
1577
+ responses:
1578
+ '200':
1579
+ description: search results
1580
+ content:
1581
+ application/json:
1582
+ schema:
1583
+ $ref: '#/components/schemas/bookingsPackageSearchReturn'
1484
1584
  /products/{appKey}/{userId}/search:
1485
1585
  post:
1486
1586
  security:
@@ -107,6 +107,7 @@ const $bookingsProductSearch = plugins => async ({
107
107
  payload,
108
108
  typeDefsAndQueries,
109
109
  requestId,
110
+ userId,
110
111
  });
111
112
  return results;
112
113
  };
@@ -130,6 +131,38 @@ const bookingsProductSearch = plugins => async (req, res, next) => {
130
131
  }
131
132
  };
132
133
 
134
+ const getProductPackages = plugins => async (req, res, next) => {
135
+ const {
136
+ axios,
137
+ params: { appKey, userId, hint },
138
+ body: payload,
139
+ } = req;
140
+ try {
141
+ const app = plugins.find(({ name }) => name === appKey);
142
+ // const app = load(appKey);
143
+ const userAppKeys = (await UserAppKey.findOne({
144
+ where: {
145
+ userId,
146
+ integrationId: appKey,
147
+ ...(hint ? { hint } : {}),
148
+ },
149
+ }));
150
+ assert(userAppKeys, 'could not find the app key');
151
+ assert(app.getProductPackages, `getProductPackages is not available for ${appKey}`);
152
+ const token = await userAppKeys.token;
153
+ const results = await app.getProductPackages({
154
+ axios,
155
+ token,
156
+ payload,
157
+ typeDefsAndQueries,
158
+ requestId: req.requestId,
159
+ });
160
+ return res.json(results);
161
+ } catch (err) {
162
+ return next(err);
163
+ }
164
+ };
165
+
133
166
  const bookingsAvailabilitySearch = plugins => async (req, res, next) => {
134
167
  const {
135
168
  axios,
@@ -227,7 +260,6 @@ const searchQuote = plugins => async (req, res, next) => {
227
260
  }));
228
261
  assert(userAppKeys, 'could not find the app key');
229
262
  const token = await userAppKeys.token;
230
- assert(payload.id, 'the availability id is required');
231
263
  const results = await app.searchQuote({
232
264
  axios,
233
265
  token,
@@ -404,6 +436,7 @@ module.exports = plugins => ({
404
436
  bookingsCancel: bookingsCancel(plugins),
405
437
  $bookingsProductSearch,
406
438
  bookingsProductSearch: bookingsProductSearch(plugins),
439
+ getProductPackages: getProductPackages(plugins),
407
440
  bookingsAvailabilitySearch: bookingsAvailabilitySearch(plugins),
408
441
  $bookingsAvailabilityCalendar,
409
442
  bookingsAvailabilityCalendar: bookingsAvailabilityCalendar(plugins),
@@ -50,6 +50,8 @@ const UserAppKey = db.define('UserAppKey', {
50
50
  token: {
51
51
  type: Sequelize.VIRTUAL,
52
52
  async get() {
53
+ if (!this.getDataValue('appKey')) return {};
54
+ if (!decrypt(this.getDataValue('appKey'))) return {};
53
55
  const sqldb = require('./index');
54
56
  const userIntegrationSettings = await sqldb.UserIntegrationSettings.findOne({
55
57
  where: { userId: this.getDataValue('userId'), integrationId: this.getDataValue('integrationId') },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ti2",
3
- "version": "1.0.71",
3
+ "version": "1.0.73",
4
4
  "description": "Tourist Industry Exchange (TI2)",
5
5
  "main": "index.js",
6
6
  "scripts": {