ti2 1.0.45 → 1.0.46

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
@@ -194,6 +194,20 @@ components:
194
194
  type: array
195
195
  items:
196
196
  type: string
197
+ desk:
198
+ type: object
199
+ properties:
200
+ id:
201
+ type: string
202
+ name:
203
+ type: string
204
+ agent:
205
+ type: object
206
+ properties:
207
+ id:
208
+ type: string
209
+ name:
210
+ type: string
197
211
  bookingSearchQuery:
198
212
  type: object
199
213
  additionalProperties: true
@@ -558,7 +572,8 @@ paths:
558
572
  description: success
559
573
  content:
560
574
  application/json:
561
- schema: '#/components/schemas/AppTokenList'
575
+ schema:
576
+ $ref: '#/components/schemas/AppTokenList'
562
577
  /{app}/{userId}:
563
578
  security:
564
579
  - bearerAuth: ['app']
@@ -598,7 +613,8 @@ paths:
598
613
  description: success
599
614
  content:
600
615
  application/json:
601
- schema: '#/components/schemas/Message'
616
+ schema:
617
+ $ref: '#/components/schemas/Message'
602
618
  delete:
603
619
  tags:
604
620
  - app
@@ -634,7 +650,8 @@ paths:
634
650
  description: success
635
651
  content:
636
652
  application/json:
637
- schema: '#/components/schemas/Message'
653
+ schema:
654
+ $ref: '#/components/schemas/Message'
638
655
  /{app}/{userId}/{hint}/token:
639
656
  get:
640
657
  tags:
@@ -672,7 +689,8 @@ paths:
672
689
  description: success
673
690
  content:
674
691
  application/json:
675
- schema: '#/components/schemas/UserApp'
692
+ schema:
693
+ $ref: '#/components/schemas/UserApp'
676
694
  /{app}/{userId}/token:
677
695
  get:
678
696
  tags:
@@ -703,7 +721,8 @@ paths:
703
721
  description: success
704
722
  content:
705
723
  application/json:
706
- schema: '#/components/schemas/UserApp'
724
+ schema:
725
+ $ref: '#/components/schemas/UserApp'
707
726
  /{app}/{userId}/validate:
708
727
  post:
709
728
  tags:
@@ -740,7 +759,8 @@ paths:
740
759
  description: success
741
760
  content:
742
761
  application/json:
743
- schema: '#/components/schemas/Message'
762
+ schema:
763
+ $ref: '#/components/schemas/Message'
744
764
 
745
765
  /{app}/{userId}/jobRun:
746
766
  security:
@@ -779,7 +799,8 @@ paths:
779
799
  description: success
780
800
  content:
781
801
  application/json:
782
- schema: '#/components/schemas/JobStatus'
802
+ schema:
803
+ $ref: '#/components/schemas/JobStatus'
783
804
  /{app}/{userId}/{hint}/jobRun:
784
805
  security:
785
806
  - bearerAuth: ['app', 'user', 'admin']
@@ -824,7 +845,8 @@ paths:
824
845
  description: success
825
846
  content:
826
847
  application/json:
827
- schema: '#/components/schemas/JobStatus'
848
+ schema:
849
+ $ref: '#/components/schemas/JobStatus'
828
850
  /{app}/{userId}/{jobId}/jobStatus:
829
851
  security:
830
852
  - bearerAuth: ['app', 'user', 'admin']
@@ -858,11 +880,12 @@ paths:
858
880
  schema:
859
881
  type: string
860
882
  responses:
861
- 200:
883
+ '200':
862
884
  description: success
863
885
  content:
864
886
  application/json:
865
- schema: '#/components/schemas/JobStatus'
887
+ schema:
888
+ $ref: '#/components/schemas/JobStatus'
866
889
  /user/{userId}/apps:
867
890
  get:
868
891
  security:
@@ -885,7 +908,8 @@ paths:
885
908
  description: success
886
909
  content:
887
910
  application/json:
888
- schema: '#/components/schemas/AppTokenList'
911
+ schema:
912
+ $ref: '#/components/schemas/AppTokenList'
889
913
  /app/{appKey}/methods:
890
914
  get:
891
915
  security:
@@ -907,7 +931,8 @@ paths:
907
931
  description: the methods available
908
932
  content:
909
933
  appication/json:
910
- schema: '#/components/schemas/appMethods'
934
+ schema:
935
+ $ref: '#/components/schemas/appMethods'
911
936
  /settings/{appKey}/{userId}:
912
937
  post:
913
938
  security:
@@ -938,12 +963,6 @@ paths:
938
963
  application/json:
939
964
  schema:
940
965
  $ref: '#/components/schemas/settingsBody'
941
- responses:
942
- 200:
943
- description: success
944
- content:
945
- application/json:
946
- schema: '#/components/schemas/Success'
947
966
  get:
948
967
  security:
949
968
  - bearerAuth: ['admin', 'user']
@@ -971,7 +990,8 @@ paths:
971
990
  description: success
972
991
  content:
973
992
  application/json:
974
- schema: '#/components/schemas/settingsBody'
993
+ schema:
994
+ $ref: '#/components/schemas/settingsBody'
975
995
  delete:
976
996
  security:
977
997
  - bearerAuth: ['admin', 'user']
@@ -1000,6 +1020,156 @@ paths:
1000
1020
  content:
1001
1021
  application/json:
1002
1022
  $ref: '#/components/schemas/Status'
1023
+ /affiliate/{appKey}/{userId}/desks:
1024
+ get:
1025
+ security:
1026
+ - bearerAuth: ['admin', 'user']
1027
+ tags:
1028
+ - bookings
1029
+ summary: Gets all desks for this affiliate
1030
+ operationId: getAffiliateDesks
1031
+ parameters:
1032
+ - name: appKey
1033
+ in: path
1034
+ description: name of the app to get the desks for (defaults to first token found)
1035
+ required: true
1036
+ example: 'fareharbor'
1037
+ schema:
1038
+ type: string
1039
+ - name: userId
1040
+ in: path
1041
+ description: the user/company that the appKey belongs to
1042
+ required: true
1043
+ schema:
1044
+ type: string
1045
+ responses:
1046
+ '200':
1047
+ description: desks
1048
+ content:
1049
+ application/json:
1050
+ schema:
1051
+ type: object
1052
+ properties:
1053
+ desks:
1054
+ type: array
1055
+ items:
1056
+ $ref: '#/components/schemas/desk'
1057
+ /affiliate/{appKey}/{userId}/{hint}/desks:
1058
+ get:
1059
+ security:
1060
+ - bearerAuth: ['admin', 'user']
1061
+ tags:
1062
+ - bookings
1063
+ summary: Gets all desks for this affiliate
1064
+ operationId: getAffiliateDesks
1065
+ parameters:
1066
+ - name: appKey
1067
+ in: path
1068
+ description: name of the app to get the desks for the token using the hint
1069
+ required: true
1070
+ example: 'fareharbor'
1071
+ schema:
1072
+ type: string
1073
+ - name: userId
1074
+ in: path
1075
+ description: the user/company that the appKey belongs to
1076
+ required: true
1077
+ schema:
1078
+ type: string
1079
+ - name: hint
1080
+ in: path
1081
+ description: a specific token hint to be used
1082
+ required: true
1083
+ example: 'fareharbor-helloworld'
1084
+ schema:
1085
+ type: string
1086
+ responses:
1087
+ '200':
1088
+ description: desks
1089
+ content:
1090
+ application/json:
1091
+ schema:
1092
+ type: object
1093
+ properties:
1094
+ desks:
1095
+ type: array
1096
+ items:
1097
+ $ref: '#/components/schemas/desk'
1098
+ /affiliate/{appKey}/{userId}/agents:
1099
+ get:
1100
+ security:
1101
+ - bearerAuth: ['admin', 'user']
1102
+ tags:
1103
+ - bookings
1104
+ summary: Gets all agents for this affiliate
1105
+ operationId: getAffiliateAgents
1106
+ parameters:
1107
+ - name: appKey
1108
+ in: path
1109
+ description: name of the app to get the agents for (defaults to first token found)
1110
+ required: true
1111
+ example: 'fareharbor'
1112
+ schema:
1113
+ type: string
1114
+ - name: userId
1115
+ in: path
1116
+ description: the user/company that the appKey belongs to
1117
+ required: true
1118
+ schema:
1119
+ type: string
1120
+ responses:
1121
+ '200':
1122
+ description: agents
1123
+ content:
1124
+ application/json:
1125
+ schema:
1126
+ type: object
1127
+ properties:
1128
+ agents:
1129
+ type: array
1130
+ items:
1131
+ $ref: '#/components/schemas/agent'
1132
+ /affiliate/{appKey}/{userId}/{hint}/agents:
1133
+ get:
1134
+ security:
1135
+ - bearerAuth: ['admin', 'user']
1136
+ tags:
1137
+ - bookings
1138
+ summary: Gets all agents for this affiliate
1139
+ operationId: getAffiliateAgents
1140
+ parameters:
1141
+ - name: appKey
1142
+ in: path
1143
+ description: name of the app to get the agents for the token using the hint
1144
+ required: true
1145
+ example: 'fareharbor'
1146
+ schema:
1147
+ type: string
1148
+ - name: userId
1149
+ in: path
1150
+ description: the user/company that the appKey belongs to
1151
+ required: true
1152
+ schema:
1153
+ type: string
1154
+ - name: hint
1155
+ in: path
1156
+ description: a specific token hint to be used
1157
+ required: true
1158
+ example: 'fareharbor-helloworld'
1159
+ schema:
1160
+ type: string
1161
+ responses:
1162
+ '200':
1163
+ description: agents
1164
+ content:
1165
+ application/json:
1166
+ schema:
1167
+ type: object
1168
+ properties:
1169
+ agents:
1170
+ type: array
1171
+ items:
1172
+ $ref: '#/components/schemas/agent'
1003
1173
  /bookings/{appKey}/{userId}/search:
1004
1174
  post:
1005
1175
  security:
@@ -33,7 +33,7 @@ const bookingsSearch = plugins => async (req, res, next) => {
33
33
  });
34
34
  assert(userAppKeys, 'could not find the app key');
35
35
  const token = await userAppKeys.token;
36
- const search = app.searchHotelBooking || app.searchBooking;
36
+ const search = (app.searchHotelBooking || app.searchBooking).bind(app);
37
37
  const results = await search({
38
38
  token,
39
39
  payload: body,
@@ -232,6 +232,62 @@ const createBooking = plugins => async (req, res, next) => {
232
232
  }
233
233
  };
234
234
 
235
+ const getAffiliateAgents = plugins => async (req, res, next) => {
236
+ const {
237
+ params: { appKey, userId, hint },
238
+ body: payload,
239
+ } = req;
240
+ try {
241
+ const app = plugins.find(({ name }) => name === appKey);
242
+ // const app = load(appKey);
243
+ const userAppKeys = (await UserAppKey.findOne({
244
+ where: {
245
+ userId,
246
+ integrationId: appKey,
247
+ ...(hint ? { hint } : {}),
248
+ },
249
+ }));
250
+ assert(userAppKeys, 'could not find the app key');
251
+ const token = await userAppKeys.token;
252
+ assert(app.getAffiliateAgents, `getAffiliateAgents is not available for ${appKey}`);
253
+ const results = await app.getAffiliateAgents({
254
+ token,
255
+ payload,
256
+ });
257
+ return res.json(results);
258
+ } catch (err) {
259
+ return next(err);
260
+ }
261
+ };
262
+
263
+ const getAffiliateDesks = plugins => async (req, res, next) => {
264
+ const {
265
+ params: { appKey, userId, hint },
266
+ body: payload,
267
+ } = req;
268
+ try {
269
+ const app = plugins.find(({ name }) => name === appKey);
270
+ // const app = load(appKey);
271
+ const userAppKeys = (await UserAppKey.findOne({
272
+ where: {
273
+ userId,
274
+ integrationId: appKey,
275
+ ...(hint ? { hint } : {}),
276
+ },
277
+ }));
278
+ assert(userAppKeys, 'could not find the app key');
279
+ const token = await userAppKeys.token;
280
+ assert(app.getAffiliateDesks, `getAffiliateDesks is not available for ${appKey}`);
281
+ const results = await app.getAffiliateDesks({
282
+ token,
283
+ payload,
284
+ });
285
+ return res.json(results);
286
+ } catch (err) {
287
+ return next(err);
288
+ }
289
+ };
290
+
235
291
  module.exports = plugins => ({
236
292
  bookingsSearch: bookingsSearch(plugins),
237
293
  bookingsCancel: bookingsCancel(plugins),
@@ -242,4 +298,6 @@ module.exports = plugins => ({
242
298
  bookingsAvailabilityCalendar: bookingsAvailabilityCalendar(plugins),
243
299
  searchQuote: searchQuote(plugins),
244
300
  createBooking: createBooking(plugins),
301
+ getAffiliateAgents: getAffiliateAgents(plugins),
302
+ getAffiliateDesks: getAffiliateDesks(plugins),
245
303
  });
@@ -18,6 +18,14 @@ const typeDefs = `
18
18
  currencyPrecision: Int
19
19
  currency: String
20
20
  }
21
+ type Agent {
22
+ id: Int
23
+ name: String
24
+ }
25
+ type Desk {
26
+ id: Int
27
+ name: String
28
+ }
21
29
  type Query {
22
30
  id: ID
23
31
  orderId: ID
@@ -42,6 +50,8 @@ const typeDefs = `
42
50
  resellerReference: String
43
51
  publicUrl: String
44
52
  privateUrl: String
53
+ agent: Agent
54
+ desk: Desk
45
55
  }
46
56
  `;
47
57
 
@@ -86,6 +96,14 @@ const query = `{
86
96
  resellerReference
87
97
  publicUrl
88
98
  privateUrl
99
+ agent {
100
+ id
101
+ name
102
+ }
103
+ desk {
104
+ id
105
+ name
106
+ }
89
107
  }`;
90
108
 
91
109
  module.exports = {
@@ -7,7 +7,7 @@ const typeDefs = `
7
7
  type Pricing {
8
8
  original: Int
9
9
  retail: Int
10
- currency: Int
10
+ currency: String
11
11
  currencyPrecision: Int
12
12
  }
13
13
  type Unit {
package/index.js CHANGED
@@ -241,7 +241,7 @@ module.exports = async ({
241
241
  return next(err);
242
242
  }
243
243
  if (process.env.CONSOLE_ERRORS || process.env.JEST_WORKER_ID) {
244
- console.error(R.path(['response', 'data'], err), err.message);
244
+ console.error(R.path(['response', 'data'], err), err);
245
245
  }
246
246
  return res.status((() => {
247
247
  if (!isNumber(err.status)) return 500;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ti2",
3
- "version": "1.0.45",
3
+ "version": "1.0.46",
4
4
  "description": "Tourist Industry Exchange (TI2)",
5
5
  "main": "index.js",
6
6
  "scripts": {