ti2 1.0.14 → 1.0.15

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
@@ -816,6 +816,97 @@ paths:
816
816
  application/json:
817
817
  schema:
818
818
  $ref: '#/components/schemas/bookingsProductSearchReturn'
819
+ /bookings/{appKey}/{userId}/availabilitycalendar:
820
+ post:
821
+ security:
822
+ - bearerAuth: ['admin', 'user']
823
+ tags:
824
+ - bookings
825
+ summary: Availability Search
826
+ operationId: bookingsAvailabilityCalendar
827
+ parameters:
828
+ - name: appKey
829
+ in: path
830
+ description: app to search availability for, defaults to first token
831
+ required: true
832
+ example: 'travelgate-hotelx'
833
+ schema:
834
+ type: string
835
+ - name: userId
836
+ in: path
837
+ description: the user/company that the appKey belongs to
838
+ required: true
839
+ schema:
840
+ type: string
841
+ requestBody:
842
+ description: both app details
843
+ required: true
844
+ content:
845
+ application/json:
846
+ schema:
847
+ $ref: '#/components/schemas/AnyValue'
848
+ responses:
849
+ '200':
850
+ description: search results
851
+ content:
852
+ application/json:
853
+ schema:
854
+ type: object
855
+ properties:
856
+ availability:
857
+ type: array
858
+ required: true
859
+ items:
860
+ $ref: '#/components/schemas/availabilityItem'
861
+ /bookings/{appKey}/{userId}/{hint}/availabilitycalendar:
862
+ post:
863
+ security:
864
+ - bearerAuth: ['admin', 'user']
865
+ tags:
866
+ - bookings
867
+ summary: Availability Search for an specific hint
868
+ operationId: bookingsAvailabilityCalendar
869
+ parameters:
870
+ - name: appKey
871
+ in: path
872
+ description: app to search availability for, defaults to first token
873
+ required: true
874
+ example: 'travelgate-hotelx'
875
+ schema:
876
+ type: string
877
+ - name: userId
878
+ in: path
879
+ description: the user/company that the appKey belongs to
880
+ required: true
881
+ schema:
882
+ type: string
883
+ - name: hint
884
+ in: path
885
+ description: a specific token hint to be used
886
+ required: true
887
+ example: 'travelgate-australia'
888
+ schema:
889
+ type: string
890
+ requestBody:
891
+ description: both app details
892
+ required: true
893
+ content:
894
+ application/json:
895
+ schema:
896
+ $ref: '#/components/schemas/AnyValue'
897
+ responses:
898
+ '200':
899
+ description: search results
900
+ content:
901
+ application/json:
902
+ schema:
903
+ type: object
904
+ properties:
905
+ availability:
906
+ type: array
907
+ required: true
908
+ items:
909
+ $ref: '#/components/schemas/availabilityItem'
819
910
  /bookings/{appKey}/{userId}/availability:
820
911
  post:
821
912
  security:
@@ -110,6 +110,33 @@ const bookingsAvailabilitySearch = plugins => async (req, res, next) => {
110
110
  }
111
111
  };
112
112
 
113
+ const bookingsAvailabilityCalendar = plugins => async (req, res, next) => {
114
+ const {
115
+ params: { appKey, userId, hint },
116
+ body: payload,
117
+ } = req;
118
+ try {
119
+ const app = plugins.find(({ name }) => name === appKey);
120
+ // const app = load(appKey);
121
+ const userAppKeys = (await UserAppKey.findOne({
122
+ where: {
123
+ userId,
124
+ integrationId: appKey,
125
+ ...(hint ? { hint } : {}),
126
+ },
127
+ }));
128
+ assert(userAppKeys, 'could not find the app key');
129
+ const token = userAppKeys.appKey;
130
+ const results = await app.availabilityCalendar({
131
+ token,
132
+ payload,
133
+ });
134
+ return res.json(results);
135
+ } catch (err) {
136
+ return next(err);
137
+ }
138
+ };
139
+
113
140
  const searchQuote = plugins => async (req, res, next) => {
114
141
  const {
115
142
  params: { appKey, userId, hint },
@@ -171,6 +198,7 @@ module.exports = plugins => ({
171
198
  bookingsCancel: bookingsCancel(plugins),
172
199
  bookingsProductSearch: bookingsProductSearch(plugins),
173
200
  bookingsAvailabilitySearch: bookingsAvailabilitySearch(plugins),
201
+ bookingsAvailabilityCalendar: bookingsAvailabilityCalendar(plugins),
174
202
  searchQuote: searchQuote(plugins),
175
203
  createBooking: createBooking(plugins),
176
204
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ti2",
3
- "version": "1.0.14",
3
+ "version": "1.0.15",
4
4
  "description": "Tourist Industry Exchange (TI2)",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/test/plugin.js CHANGED
@@ -363,7 +363,22 @@ class Plugin {
363
363
  searchAvailability() {
364
364
  // return (args);
365
365
  }
366
-
366
+ /**
367
+ * Retrieve an availability calendar over a date range
368
+ * @async
369
+ * @param {Object} args - Availability search arguments.
370
+ * @param {Object} args.token - A token definition, it's content varies between integrations.
371
+ * @param {Object} args.payload - Search spect object.
372
+ * @param {string} args.payload.dateFormat - Date format sent, using [momentjs formatting](https://momentjs.com/docs/#/parsing/string-format/).
373
+ * @param {string} args.payload.travelDateStart - Date of travel start.
374
+ * @param {string} args.payload.travelDateEnd - Date of travel end.
375
+ * @param {Occupancy[]} args.payload.occupancies - Occupancy detail.
376
+ * @returns {object} retVal - the return object
377
+ * @returns {Availability[]} retVal.availability - Array of availability objects
378
+ */
379
+ availabilityCalndar() {
380
+ // return (args);
381
+ }
367
382
  /**
368
383
  * A quote return spec
369
384
  * @typedef {Object} Quote