ti2 1.0.49 → 1.0.50

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
@@ -208,6 +208,13 @@ components:
208
208
  type: string
209
209
  name:
210
210
  type: string
211
+ pickuppoint:
212
+ type: object
213
+ properties:
214
+ id:
215
+ type: string
216
+ name:
217
+ type: string
211
218
  bookingSearchQuery:
212
219
  type: object
213
220
  additionalProperties: true
@@ -1170,6 +1177,81 @@ paths:
1170
1177
  type: array
1171
1178
  items:
1172
1179
  $ref: '#/components/schemas/agent'
1180
+ /{appKey}/{userId}/pickup-points:
1181
+ get:
1182
+ security:
1183
+ - bearerAuth: ['admin', 'user']
1184
+ tags:
1185
+ - bookings
1186
+ summary: Gets all pickup points for this supplier
1187
+ operationId: getPickupPoints
1188
+ parameters:
1189
+ - name: appKey
1190
+ in: path
1191
+ description: name of the app to get the pickup points from (defaults to first token found)
1192
+ required: true
1193
+ example: 'fareharbor'
1194
+ schema:
1195
+ type: string
1196
+ - name: userId
1197
+ in: path
1198
+ description: the user/company that the appKey belongs to
1199
+ required: true
1200
+ schema:
1201
+ type: string
1202
+ responses:
1203
+ '200':
1204
+ description: pickup points
1205
+ content:
1206
+ application/json:
1207
+ schema:
1208
+ type: object
1209
+ properties:
1210
+ pickupPoints:
1211
+ type: array
1212
+ items:
1213
+ $ref: '#/components/schemas/pickuppoint'
1214
+ /{appKey}/{userId}/{hint}/pickup-points:
1215
+ get:
1216
+ security:
1217
+ - bearerAuth: ['admin', 'user']
1218
+ tags:
1219
+ - bookings
1220
+ summary: Gets all pickup points for this supplier
1221
+ operationId: getPickupPoints
1222
+ parameters:
1223
+ - name: appKey
1224
+ in: path
1225
+ description: name of the app to get the pickup points from (defaults to first token found) using the hint
1226
+ required: true
1227
+ example: 'fareharbor'
1228
+ schema:
1229
+ type: string
1230
+ - name: userId
1231
+ in: path
1232
+ description: the user/company that the appKey belongs to
1233
+ required: true
1234
+ schema:
1235
+ type: string
1236
+ - name: hint
1237
+ in: path
1238
+ description: a specific token hint to be used
1239
+ required: true
1240
+ example: 'fareharbor-helloworld'
1241
+ schema:
1242
+ type: string
1243
+ responses:
1244
+ '200':
1245
+ description: pickup points
1246
+ content:
1247
+ application/json:
1248
+ schema:
1249
+ type: object
1250
+ properties:
1251
+ pickupPoints:
1252
+ type: array
1253
+ items:
1254
+ $ref: '#/components/schemas/pickuppoint'
1173
1255
  /bookings/{appKey}/{userId}/search:
1174
1256
  post:
1175
1257
  security:
@@ -5,6 +5,7 @@ const { typeDefs: productTypeDefs, query: productQuery } = require('./graphql-sc
5
5
  const { typeDefs: availTypeDefs, query: availQuery } = require('./graphql-schemas/availability');
6
6
  const { typeDefs: bookingTypeDefs, query: bookingQuery } = require('./graphql-schemas/booking');
7
7
  const { typeDefs: rateTypeDefs, query: rateQuery } = require('./graphql-schemas/rate');
8
+ const { typeDefs: pickupTypeDefs, query: pickupQuery } = require('./graphql-schemas/pickup-point');
8
9
 
9
10
  const typeDefsAndQueries = {
10
11
  productTypeDefs,
@@ -15,6 +16,8 @@ const typeDefsAndQueries = {
15
16
  bookingQuery,
16
17
  rateTypeDefs,
17
18
  rateQuery,
19
+ pickupTypeDefs,
20
+ pickupQuery,
18
21
  };
19
22
 
20
23
  const bookingsSearch = plugins => async (req, res, next) => {
@@ -305,6 +308,35 @@ const getAffiliateDesks = plugins => async (req, res, next) => {
305
308
  }
306
309
  };
307
310
 
311
+ const getPickupPoints = plugins => async (req, res, next) => {
312
+ const {
313
+ params: { appKey, userId, hint },
314
+ body: payload,
315
+ } = req;
316
+ try {
317
+ const app = plugins.find(({ name }) => name === appKey);
318
+ // const app = load(appKey);
319
+ const userAppKeys = (await UserAppKey.findOne({
320
+ where: {
321
+ userId,
322
+ integrationId: appKey,
323
+ ...(hint ? { hint } : {}),
324
+ },
325
+ }));
326
+ assert(userAppKeys, 'could not find the app key');
327
+ const token = await userAppKeys.token;
328
+ assert(app.getPickupPoints, `getPickupPoints is not available for ${appKey}`);
329
+ const results = await app.getPickupPoints({
330
+ token,
331
+ payload,
332
+ typeDefsAndQueries,
333
+ });
334
+ return res.json(results);
335
+ } catch (err) {
336
+ return next(err);
337
+ }
338
+ };
339
+
308
340
  module.exports = plugins => ({
309
341
  bookingsSearch: bookingsSearch(plugins),
310
342
  bookingsCancel: bookingsCancel(plugins),
@@ -317,4 +349,5 @@ module.exports = plugins => ({
317
349
  createBooking: createBooking(plugins),
318
350
  getAffiliateAgents: getAffiliateAgents(plugins),
319
351
  getAffiliateDesks: getAffiliateDesks(plugins),
352
+ getPickupPoints: getPickupPoints(plugins),
320
353
  });
@@ -0,0 +1,16 @@
1
+ const typeDefs = `
2
+ type Query {
3
+ id: ID
4
+ name: String
5
+ }
6
+ `;
7
+
8
+ const query = `{
9
+ id
10
+ name
11
+ }`;
12
+
13
+ module.exports = {
14
+ typeDefs,
15
+ query,
16
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ti2",
3
- "version": "1.0.49",
3
+ "version": "1.0.50",
4
4
  "description": "Tourist Industry Exchange (TI2)",
5
5
  "main": "index.js",
6
6
  "scripts": {