ti2 1.0.7 → 1.0.11
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/.github/workflows/deploy.yml +1 -2
- package/.github/workflows/tests.yml +32 -8
- package/README.md +51 -11
- package/api.yml +504 -15
- package/controllers/__tests__/admin.js +27 -30
- package/controllers/__tests__/app.js +33 -37
- package/controllers/__tests__/bookings.js +129 -35
- package/controllers/__tests__/ping.js +5 -10
- package/controllers/__tests__/user.js +57 -62
- package/controllers/admin.js +28 -5
- package/controllers/bookings.js +114 -1
- package/controllers/user.js +2 -2
- package/index.js +3 -1
- package/jsdoc.conf.json +25 -0
- package/migrations/20200114173707-addTCApp.js +0 -3
- package/package.json +9 -6
- package/seeders/.gitkeep +0 -0
- package/test/plugin.js +415 -0
- package/test/slugify.js +21 -0
- package/test/utils.js +95 -96
package/api.yml
CHANGED
|
@@ -141,6 +141,7 @@ components:
|
|
|
141
141
|
type: string
|
|
142
142
|
bookingSearchQuery:
|
|
143
143
|
type: object
|
|
144
|
+
additionalProperties: true
|
|
144
145
|
properties:
|
|
145
146
|
bookingId:
|
|
146
147
|
type: string
|
|
@@ -172,6 +173,7 @@ components:
|
|
|
172
173
|
default: "DD/MM/YYYY"
|
|
173
174
|
bookingDetail:
|
|
174
175
|
type: object
|
|
176
|
+
additionalProperties: true
|
|
175
177
|
properties:
|
|
176
178
|
id:
|
|
177
179
|
type: string
|
|
@@ -181,7 +183,15 @@ components:
|
|
|
181
183
|
type: string
|
|
182
184
|
required: true
|
|
183
185
|
description: The booking status
|
|
184
|
-
|
|
186
|
+
bookingSearchQueryResults:
|
|
187
|
+
type: object
|
|
188
|
+
additionalProperties: true
|
|
189
|
+
properties:
|
|
190
|
+
bookings:
|
|
191
|
+
type: object
|
|
192
|
+
required: true
|
|
193
|
+
items:
|
|
194
|
+
$ref: '#/components/schemas/bookingDetail'
|
|
185
195
|
bookingDetailsForCancel:
|
|
186
196
|
allOf: # Combines the BasicErrorModel and the inline model
|
|
187
197
|
- $ref: '#/components/schemas/bookingDetail'
|
|
@@ -191,6 +201,89 @@ components:
|
|
|
191
201
|
type: integer
|
|
192
202
|
required: true
|
|
193
203
|
description: The unix time the cancellation was sent
|
|
204
|
+
cancellationReturn:
|
|
205
|
+
type: object
|
|
206
|
+
properties:
|
|
207
|
+
cancellation:
|
|
208
|
+
type: object
|
|
209
|
+
allOf: # Combines the BasicErrorModel and the inline model
|
|
210
|
+
- $ref: '#/components/schemas/bookingDetail'
|
|
211
|
+
bookingsProductQuery:
|
|
212
|
+
type: object
|
|
213
|
+
additionalProperties: true
|
|
214
|
+
description: Additional properties may be included
|
|
215
|
+
properties:
|
|
216
|
+
productName:
|
|
217
|
+
type: string
|
|
218
|
+
required: false
|
|
219
|
+
description: Product Name wildcard match
|
|
220
|
+
example: '*bus*'
|
|
221
|
+
bookingsProductSearchReturn:
|
|
222
|
+
type: object
|
|
223
|
+
additionalProperties: true
|
|
224
|
+
description: Additional properties may be included
|
|
225
|
+
properties:
|
|
226
|
+
products:
|
|
227
|
+
type: array
|
|
228
|
+
required: false
|
|
229
|
+
description: Product Search Results
|
|
230
|
+
items:
|
|
231
|
+
type: object
|
|
232
|
+
accommodation:
|
|
233
|
+
type: array
|
|
234
|
+
required: false,
|
|
235
|
+
decription: Accommodation search results
|
|
236
|
+
items:
|
|
237
|
+
type: object
|
|
238
|
+
pricingItem:
|
|
239
|
+
type: object
|
|
240
|
+
additionalProperties: true
|
|
241
|
+
properties:
|
|
242
|
+
original:
|
|
243
|
+
type: integer
|
|
244
|
+
retail:
|
|
245
|
+
type: integer
|
|
246
|
+
net:
|
|
247
|
+
type: integer
|
|
248
|
+
currency:
|
|
249
|
+
type: string
|
|
250
|
+
example: "USD"
|
|
251
|
+
currencyPrecision:
|
|
252
|
+
type: integer
|
|
253
|
+
includedTaxes:
|
|
254
|
+
type: array
|
|
255
|
+
items:
|
|
256
|
+
type: object
|
|
257
|
+
additionalProperties: true
|
|
258
|
+
properties:
|
|
259
|
+
name:
|
|
260
|
+
type: string
|
|
261
|
+
retail:
|
|
262
|
+
type: integer
|
|
263
|
+
net:
|
|
264
|
+
type: integer
|
|
265
|
+
availabilityItem:
|
|
266
|
+
type: object
|
|
267
|
+
additionalProperties: true
|
|
268
|
+
properties:
|
|
269
|
+
id:
|
|
270
|
+
type: string
|
|
271
|
+
required: true
|
|
272
|
+
description: An availability Id that can be used for quoting
|
|
273
|
+
pricing:
|
|
274
|
+
$ref: '#/components/schemas/pricingItem'
|
|
275
|
+
required: false
|
|
276
|
+
cancelPolicy:
|
|
277
|
+
type: string
|
|
278
|
+
required: false
|
|
279
|
+
bookingRequest:
|
|
280
|
+
type: object
|
|
281
|
+
additionalProperties: true
|
|
282
|
+
required: true
|
|
283
|
+
properties:
|
|
284
|
+
id:
|
|
285
|
+
type: string
|
|
286
|
+
description: a quote Id to make a reservation for
|
|
194
287
|
paths:
|
|
195
288
|
/ping:
|
|
196
289
|
get:
|
|
@@ -227,6 +320,30 @@ paths:
|
|
|
227
320
|
application/json:
|
|
228
321
|
schema:
|
|
229
322
|
$ref: '#/components/schemas/Message'
|
|
323
|
+
|
|
324
|
+
/app/{appKey}:
|
|
325
|
+
delete:
|
|
326
|
+
security:
|
|
327
|
+
- bearerAuth: ['admin']
|
|
328
|
+
tags:
|
|
329
|
+
- admin
|
|
330
|
+
summary: Should delete an App, the name of the app should be url safe (no spaces)
|
|
331
|
+
operationId: deleteApp
|
|
332
|
+
parameters:
|
|
333
|
+
- name: appKey
|
|
334
|
+
in: path
|
|
335
|
+
description: App name to delete, should be urlsafe and have a correspondant npm package already in the required npm modules as ti2-appName
|
|
336
|
+
required: true
|
|
337
|
+
example: 'expedia'
|
|
338
|
+
schema:
|
|
339
|
+
type: string
|
|
340
|
+
responses:
|
|
341
|
+
200:
|
|
342
|
+
description: success
|
|
343
|
+
content:
|
|
344
|
+
application/json:
|
|
345
|
+
schema:
|
|
346
|
+
$ref: '#/components/schemas/Message'
|
|
230
347
|
/apps:
|
|
231
348
|
get:
|
|
232
349
|
security:
|
|
@@ -492,10 +609,12 @@ paths:
|
|
|
492
609
|
schema:
|
|
493
610
|
$ref: '#/components/schemas/bookingSearchQuery'
|
|
494
611
|
responses:
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
612
|
+
'200':
|
|
613
|
+
description: search results
|
|
614
|
+
content:
|
|
615
|
+
application/json:
|
|
616
|
+
schema:
|
|
617
|
+
$ref: '#/components/schemas/bookingSearchQueryResults'
|
|
499
618
|
/bookings/{appKey}/{userId}/{hint}/search:
|
|
500
619
|
post:
|
|
501
620
|
security:
|
|
@@ -533,10 +652,12 @@ paths:
|
|
|
533
652
|
schema:
|
|
534
653
|
$ref: '#/components/schemas/bookingSearchQuery'
|
|
535
654
|
responses:
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
655
|
+
'200':
|
|
656
|
+
description: search results
|
|
657
|
+
content:
|
|
658
|
+
application/json:
|
|
659
|
+
schema:
|
|
660
|
+
$ref: '#/components/schemas/bookingSearchQueryResults'
|
|
540
661
|
/bookings/{appKey}/{userId}/cancel:
|
|
541
662
|
post:
|
|
542
663
|
security:
|
|
@@ -567,10 +688,12 @@ paths:
|
|
|
567
688
|
schema:
|
|
568
689
|
$ref: '#/components/schemas/bookingDetailsForCancel'
|
|
569
690
|
responses:
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
691
|
+
'200':
|
|
692
|
+
description: Cancellation confirmation details
|
|
693
|
+
content:
|
|
694
|
+
application/json:
|
|
695
|
+
schema:
|
|
696
|
+
$ref: '#/components/schemas/cancellationReturn'
|
|
574
697
|
/bookings/{appKey}/{userId}/{hint}/cancel:
|
|
575
698
|
post:
|
|
576
699
|
security:
|
|
@@ -608,7 +731,373 @@ paths:
|
|
|
608
731
|
schema:
|
|
609
732
|
$ref: '#/components/schemas/bookingDetailsForCancel'
|
|
610
733
|
responses:
|
|
611
|
-
|
|
734
|
+
'200':
|
|
735
|
+
description: Cancellation confirmation details
|
|
736
|
+
content:
|
|
737
|
+
application/json:
|
|
738
|
+
schema:
|
|
739
|
+
$ref: '#/components/schemas/cancellationReturn'
|
|
740
|
+
/products/{appKey}/{userId}/search:
|
|
741
|
+
post:
|
|
742
|
+
security:
|
|
743
|
+
- bearerAuth: ['admin', 'user']
|
|
744
|
+
tags:
|
|
745
|
+
- bookings
|
|
746
|
+
summary: Product Search
|
|
747
|
+
operationId: bookingsProductSearch
|
|
748
|
+
parameters:
|
|
749
|
+
- name: appKey
|
|
750
|
+
in: path
|
|
751
|
+
description: app to search the booking products, defaults to first token
|
|
752
|
+
required: true
|
|
753
|
+
example: 'travelgate-hotelx'
|
|
754
|
+
schema:
|
|
755
|
+
type: string
|
|
756
|
+
- name: userId
|
|
757
|
+
in: path
|
|
758
|
+
description: the user/company that the appKey belongs to
|
|
759
|
+
required: true
|
|
760
|
+
schema:
|
|
761
|
+
type: string
|
|
762
|
+
requestBody:
|
|
763
|
+
description: Search query
|
|
764
|
+
required: true
|
|
765
|
+
content:
|
|
766
|
+
application/json:
|
|
767
|
+
schema:
|
|
768
|
+
$ref: '#/components/schemas/bookingsProductQuery'
|
|
769
|
+
responses:
|
|
770
|
+
'200':
|
|
771
|
+
description: search results
|
|
772
|
+
content:
|
|
773
|
+
application/json:
|
|
774
|
+
schema:
|
|
775
|
+
$ref: '#/components/schemas/bookingsProductSearchReturn'
|
|
776
|
+
/products/{appKey}/{userId}/{hint}/search:
|
|
777
|
+
post:
|
|
778
|
+
security:
|
|
779
|
+
- bearerAuth: ['admin', 'user']
|
|
780
|
+
tags:
|
|
781
|
+
- bookings
|
|
782
|
+
summary: Product Search using for an specific hint
|
|
783
|
+
operationId: bookingsProductSearch
|
|
784
|
+
parameters:
|
|
785
|
+
- name: appKey
|
|
786
|
+
in: path
|
|
787
|
+
description: app to search the booking products, defaults to first token
|
|
788
|
+
required: true
|
|
789
|
+
example: 'travelgate-hotelx'
|
|
790
|
+
schema:
|
|
791
|
+
type: string
|
|
792
|
+
- name: userId
|
|
793
|
+
in: path
|
|
794
|
+
description: the user/company that the appKey belongs to
|
|
795
|
+
required: true
|
|
796
|
+
schema:
|
|
797
|
+
type: string
|
|
798
|
+
- name: hint
|
|
799
|
+
in: path
|
|
800
|
+
description: a specific token hint to be used
|
|
801
|
+
required: true
|
|
802
|
+
example: 'travelgate-australia'
|
|
803
|
+
schema:
|
|
804
|
+
type: string
|
|
805
|
+
requestBody:
|
|
806
|
+
description: Search query
|
|
807
|
+
required: true
|
|
808
|
+
content:
|
|
809
|
+
application/json:
|
|
810
|
+
schema:
|
|
811
|
+
$ref: '#/components/schemas/bookingsProductQuery'
|
|
812
|
+
responses:
|
|
813
|
+
'200':
|
|
814
|
+
description: search results
|
|
815
|
+
content:
|
|
816
|
+
application/json:
|
|
817
|
+
schema:
|
|
818
|
+
$ref: '#/components/schemas/bookingsProductSearchReturn'
|
|
819
|
+
/bookings/{appKey}/{userId}/availability:
|
|
820
|
+
post:
|
|
821
|
+
security:
|
|
822
|
+
- bearerAuth: ['admin', 'user']
|
|
823
|
+
tags:
|
|
824
|
+
- bookings
|
|
825
|
+
summary: Availability Search
|
|
826
|
+
operationId: bookingsAvailabilitySearch
|
|
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}/availability:
|
|
862
|
+
post:
|
|
863
|
+
security:
|
|
864
|
+
- bearerAuth: ['admin', 'user']
|
|
865
|
+
tags:
|
|
866
|
+
- bookings
|
|
867
|
+
summary: Availability Search for an specific hint
|
|
868
|
+
operationId: bookingsAvailabilitySearch
|
|
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'
|
|
910
|
+
/bookings/{appKey}/{userId}/quote:
|
|
911
|
+
post:
|
|
912
|
+
security:
|
|
913
|
+
- bearerAuth: ['admin', 'user']
|
|
914
|
+
tags:
|
|
915
|
+
- bookings
|
|
916
|
+
summary: Quote an Availability
|
|
917
|
+
operationId: searchQuote
|
|
918
|
+
parameters:
|
|
919
|
+
- name: appKey
|
|
920
|
+
in: path
|
|
921
|
+
description: app to quote availability for, defaults to first token
|
|
922
|
+
required: true
|
|
923
|
+
example: 'travelgate-hotelx'
|
|
924
|
+
schema:
|
|
925
|
+
type: string
|
|
926
|
+
- name: userId
|
|
927
|
+
in: path
|
|
928
|
+
description: the user/company that the appKey belongs to
|
|
929
|
+
required: true
|
|
930
|
+
schema:
|
|
931
|
+
type: string
|
|
932
|
+
requestBody:
|
|
933
|
+
description: Availability spec to be quoted
|
|
934
|
+
required: true
|
|
612
935
|
content:
|
|
613
936
|
application/json:
|
|
614
|
-
schema:
|
|
937
|
+
schema:
|
|
938
|
+
type: object
|
|
939
|
+
additionalProperties: true
|
|
940
|
+
properties:
|
|
941
|
+
id:
|
|
942
|
+
type: string
|
|
943
|
+
required: true
|
|
944
|
+
description: An availability Id to quote
|
|
945
|
+
responses:
|
|
946
|
+
'200':
|
|
947
|
+
description: Quote Details
|
|
948
|
+
content:
|
|
949
|
+
application/json:
|
|
950
|
+
schema:
|
|
951
|
+
type: object
|
|
952
|
+
required: true
|
|
953
|
+
properties:
|
|
954
|
+
quote:
|
|
955
|
+
type: array
|
|
956
|
+
required: true
|
|
957
|
+
items:
|
|
958
|
+
type: object
|
|
959
|
+
additionalProperties: true
|
|
960
|
+
properties:
|
|
961
|
+
id:
|
|
962
|
+
type: string
|
|
963
|
+
description: a quote Id that can be use to book
|
|
964
|
+
/bookings/{appKey}/{userId}/{hint}/quote:
|
|
965
|
+
post:
|
|
966
|
+
security:
|
|
967
|
+
- bearerAuth: ['admin', 'user']
|
|
968
|
+
tags:
|
|
969
|
+
- bookings
|
|
970
|
+
summary: Quote an Availability for an specific hint
|
|
971
|
+
operationId: searchQuote
|
|
972
|
+
parameters:
|
|
973
|
+
- name: appKey
|
|
974
|
+
in: path
|
|
975
|
+
description: app to quote the availability for, defaults to first token
|
|
976
|
+
required: true
|
|
977
|
+
example: 'travelgate-hotelx'
|
|
978
|
+
schema:
|
|
979
|
+
type: string
|
|
980
|
+
- name: userId
|
|
981
|
+
in: path
|
|
982
|
+
description: the user/company that the appKey belongs to
|
|
983
|
+
required: true
|
|
984
|
+
schema:
|
|
985
|
+
type: string
|
|
986
|
+
- name: hint
|
|
987
|
+
in: path
|
|
988
|
+
description: a specific token hint to be used
|
|
989
|
+
required: true
|
|
990
|
+
example: 'travelgate-australia'
|
|
991
|
+
schema:
|
|
992
|
+
type: string
|
|
993
|
+
requestBody:
|
|
994
|
+
description: Availability spec to be quoted
|
|
995
|
+
required: true
|
|
996
|
+
content:
|
|
997
|
+
application/json:
|
|
998
|
+
schema:
|
|
999
|
+
type: object
|
|
1000
|
+
additionalProperties: true
|
|
1001
|
+
properties:
|
|
1002
|
+
id:
|
|
1003
|
+
type: string
|
|
1004
|
+
required: true
|
|
1005
|
+
description: An availability Id to quote
|
|
1006
|
+
responses:
|
|
1007
|
+
'200':
|
|
1008
|
+
description: Quote Details
|
|
1009
|
+
content:
|
|
1010
|
+
application/json:
|
|
1011
|
+
schema:
|
|
1012
|
+
type: object
|
|
1013
|
+
required: true
|
|
1014
|
+
properties:
|
|
1015
|
+
quote:
|
|
1016
|
+
type: array
|
|
1017
|
+
required: true
|
|
1018
|
+
items:
|
|
1019
|
+
type: object
|
|
1020
|
+
additionalProperties: true
|
|
1021
|
+
properties:
|
|
1022
|
+
id:
|
|
1023
|
+
type: string
|
|
1024
|
+
description: a quote Id that can be use to book
|
|
1025
|
+
/bookings/{appKey}/{userId}/booking:
|
|
1026
|
+
post:
|
|
1027
|
+
security:
|
|
1028
|
+
- bearerAuth: ['admin', 'user']
|
|
1029
|
+
tags:
|
|
1030
|
+
- bookings
|
|
1031
|
+
summary: Create a Booking
|
|
1032
|
+
operationId: createBooking
|
|
1033
|
+
parameters:
|
|
1034
|
+
- name: appKey
|
|
1035
|
+
in: path
|
|
1036
|
+
description: app to create the booking for, defaults to first token
|
|
1037
|
+
required: true
|
|
1038
|
+
example: 'travelgate-hotelx'
|
|
1039
|
+
schema:
|
|
1040
|
+
type: string
|
|
1041
|
+
- name: userId
|
|
1042
|
+
in: path
|
|
1043
|
+
description: the user/company that the appKey belongs to
|
|
1044
|
+
required: true
|
|
1045
|
+
schema:
|
|
1046
|
+
type: string
|
|
1047
|
+
requestBody:
|
|
1048
|
+
description: Booking creation payload
|
|
1049
|
+
required: true
|
|
1050
|
+
content:
|
|
1051
|
+
application/json:
|
|
1052
|
+
schema:
|
|
1053
|
+
$ref: '#/components/schemas/bookingRequest'
|
|
1054
|
+
responses:
|
|
1055
|
+
'200':
|
|
1056
|
+
description: Booking Details
|
|
1057
|
+
content:
|
|
1058
|
+
application/json:
|
|
1059
|
+
schema:
|
|
1060
|
+
$ref: '#/components/schemas/AnyValue'
|
|
1061
|
+
/bookings/{appKey}/{userId}/{hint}/booking:
|
|
1062
|
+
post:
|
|
1063
|
+
security:
|
|
1064
|
+
- bearerAuth: ['admin', 'user']
|
|
1065
|
+
tags:
|
|
1066
|
+
- bookings
|
|
1067
|
+
summary: Create a Booking for an specific hint
|
|
1068
|
+
operationId: createBooking
|
|
1069
|
+
parameters:
|
|
1070
|
+
- name: appKey
|
|
1071
|
+
in: path
|
|
1072
|
+
description: app to create the booking for, defaults to first token
|
|
1073
|
+
required: true
|
|
1074
|
+
example: 'travelgate-hotelx'
|
|
1075
|
+
schema:
|
|
1076
|
+
type: string
|
|
1077
|
+
- name: userId
|
|
1078
|
+
in: path
|
|
1079
|
+
description: the user/company that the appKey belongs to
|
|
1080
|
+
required: true
|
|
1081
|
+
schema:
|
|
1082
|
+
type: string
|
|
1083
|
+
- name: hint
|
|
1084
|
+
in: path
|
|
1085
|
+
description: a specific token hint to be used
|
|
1086
|
+
required: true
|
|
1087
|
+
example: 'travelgate-australia'
|
|
1088
|
+
schema:
|
|
1089
|
+
type: string
|
|
1090
|
+
requestBody:
|
|
1091
|
+
description: Booking creation payload
|
|
1092
|
+
required: true
|
|
1093
|
+
content:
|
|
1094
|
+
application/json:
|
|
1095
|
+
schema:
|
|
1096
|
+
$ref: '#/components/schemas/bookingRequest'
|
|
1097
|
+
responses:
|
|
1098
|
+
'200':
|
|
1099
|
+
description: Booking Details
|
|
1100
|
+
content:
|
|
1101
|
+
application/json:
|
|
1102
|
+
schema:
|
|
1103
|
+
$ref: '#/components/schemas/AnyValue'
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
/* globals describe it expect
|
|
1
|
+
/* globals describe it expect */
|
|
2
2
|
|
|
3
3
|
const chance = require('chance').Chance();
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const sqldb = require('../../models/db');
|
|
7
|
-
const { slugify } = require('../../test/utils');
|
|
4
|
+
const testUtils = require('../../test/utils');
|
|
5
|
+
const slugify = require('../../test/slugify');
|
|
8
6
|
|
|
9
7
|
const { env: { adminKey } } = process;
|
|
10
8
|
|
|
@@ -17,26 +15,24 @@ describe('admin', () => {
|
|
|
17
15
|
packageName: `ti2-${appName}`,
|
|
18
16
|
adminEmail: chance.email(),
|
|
19
17
|
};
|
|
18
|
+
const { doApiPost, doApiGet } = testUtils({
|
|
19
|
+
plugins: [appName],
|
|
20
|
+
});
|
|
20
21
|
let appKey;
|
|
21
22
|
const userId = '536830b6ed19afa44a000002';
|
|
22
|
-
afterAll(async () => {
|
|
23
|
-
await sqldb.connectionManager.close();
|
|
24
|
-
});
|
|
25
23
|
it('should be able to create an app', async () => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
expect(
|
|
32
|
-
appKey = resp.body.value;
|
|
24
|
+
({ value: appKey } = await doApiPost({
|
|
25
|
+
url: '/app',
|
|
26
|
+
token: adminKey,
|
|
27
|
+
payload: newApp,
|
|
28
|
+
}));
|
|
29
|
+
expect(appKey).toBeTruthy();
|
|
33
30
|
});
|
|
34
31
|
it('the created app should be on the list of apps', async () => {
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const { body: { integrations } } = resp;
|
|
32
|
+
const { integrations } = await doApiGet({
|
|
33
|
+
url: '/apps',
|
|
34
|
+
token: adminKey,
|
|
35
|
+
});
|
|
40
36
|
expect(integrations).toEqual(
|
|
41
37
|
expect.arrayContaining([
|
|
42
38
|
expect.objectContaining(newApp),
|
|
@@ -45,18 +41,19 @@ describe('admin', () => {
|
|
|
45
41
|
});
|
|
46
42
|
it('should be able to reset an app\'s key', async () => {
|
|
47
43
|
const url = `/app/resetAppKey/${newApp.name}`;
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const { body: { value } } = resp;
|
|
44
|
+
const { value } = await doApiGet({
|
|
45
|
+
url,
|
|
46
|
+
token: adminKey,
|
|
47
|
+
});
|
|
53
48
|
expect(value).toBeTruthy();
|
|
54
49
|
expect(value).not.toBe(appKey);
|
|
55
50
|
});
|
|
56
|
-
it
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
51
|
+
it('should be able to create a new user authentication token', async () => {
|
|
52
|
+
const { value } = await doApiPost({
|
|
53
|
+
url: '/user',
|
|
54
|
+
token: adminKey,
|
|
55
|
+
payload: { userId },
|
|
56
|
+
});
|
|
57
|
+
expect(value).toBeTruthy();
|
|
61
58
|
});
|
|
62
59
|
});
|