-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhotel-endpoints.raml
510 lines (503 loc) · 15.8 KB
/
hotel-endpoints.raml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
#%RAML 1.0
title: Hotel API
baseUri: http://hotelservices.com/api-hotel/
version: 1.0
traits:
pageable:
# used to apply paging. Example:
# get:
# is: [pageable]
queryParameters:
pageNumber:
description: Number of page to show results
type: integer
required: false
example: 20
default: 1
pageSize:
description: Number of show results
type: integer
required: false
example: 20
default: 10
securitySchemes:
customTokenSecurity:
type: x-hotel-token
description: Custom security token given by the server administrator.
describedBy:
headers:
x-hotel-token:
description: This header contains a string represening a valid token received from the server administrator.
responses:
401:
description: |
Hotel provided an invalid token (invalid or malformed token format, expired token) and couldn't be authenticated. Re-authentication is necessary.
body:
application/json:
type: authenticationError
types:
authenticationError:
type: object
properties:
desc:
type: string
required: true
description: A description of the type of the authentication error.
types:
offerPreview:
type: object
properties:
isActive:
type: boolean
offerTitle:
type: string
costPerChild:
type: number
multipleOf: 0.01
required: true
costPerAdult:
type: number
multipleOf: 0.01
required: true
maxGuests:
type: integer
minimum: 1
required: true
offerPreviewPicture: # base-64 encoded image
type: file
offer:
type: object
properties:
isActive:
type: boolean
offerTitle:
type: string
costPerChild:
type: number
multipleOf: 0.01
required: true
costPerAdult:
type: number
multipleOf: 0.01
required: true
maxGuests:
type: integer
minimum: 1
required: true
description:
type: string
offerPreviewPicture:
type: file
pictures:
type: array
items:
type: file
rooms:
type: array
required: false
items:
type: string
reservationObject:
type: object
properties:
reservation:
type: object
properties:
reservationID: integer
offerID: integer
fromTime: datetime
toTime: datetime
childrenCount: integer
adultsCount: integer
client:
type: object
properties:
clientID: integer
name: string
surname: string
room:
type: object
properties:
roomID: int
hotelRoomNumber: string
#--------------------------------------------------------------------------------------------------------
#-----------------------------------------------OFFERS---------------------------------------------------
#--------------------------------------------------------------------------------------------------------
/offers:
description: List of offers present in the system
get:
description: List all offers related to hotel
is: [pageable]
queryParameters:
isActive:
required: false
type: boolean
description: Optional parameter deciding what type of offers should be returned |
true - only active, false - only inactive, no value - all offers
responses:
200:
body:
application/json:
type: offerPreview[]
example: |
[
{
"isActive": true,
"offerTitle": "Great Offer",
"costPerChild": 120.0,
"costPerAdult": 150.0,
"maxGuests": 4,
"offerPreviewPicture": "kBKuB875JH5VJkhu",
},
{
"isActive": false,
"offerTitle": "Bad Offer",
"costPerChild": 130.0,
"costPerAdult": 130.0,
"maxGuests": 2,
"offerPreviewPicture": "kjdsf328KB53JVT9jk",
}
]
post:
description: Add new offer
body:
application/json:
type: offer
example: |
{
"isActive": true,
"offerTitle": "Awesome offer",
"costPerChild": 50,
"costPerAdult": 80,
"maxGuests": 5,
"description": "Apartment overlooking the sea",
"offerPreviewPicture": "hbUbkjd86jhVG7JFjh",
"pictures": [],
"rooms": [ "12A", "14B" ]
}
responses:
200:
description: Succesfully added. Return offerID
body:
application/json:
example: |
{ "offerID": 3 }
400:
description: Unable to add offer
body:
application/json:
example: |
{ "error": "Unable to add offer" }
/{offerID}:
uriParameters:
offerID: integer
get:
description: Gets information related to a specific offer with ID equal to offerID
responses:
200:
body:
application/json:
type: offer
example: |
{
"isActive": false,
"offerTitle": "Rich Offer",
"costPerChild": 50.0,
"costPerAdult": 60.0,
"maxGuests": 5,
"description": "Offer description",
"offerPreviewPicture": "hbUbkjd86jhVG7JFjh",
"pictures": []
}
401:
description: Offer does not belong to this hotel
404:
description: Offer not found
delete:
#Usuwanie polega na sprawdzeniu czy w systemie są jeszcze nie zrealizowane rezerwacje w ramach tej oferty.
#Jeśli tak - zwracamy błąd 409 i nie podejmujemy żadnych działań
#Jeśli nie - "odpinamy" pokoje od oferty (tabela OfferHotelRooms) i oznaczamy ofertę jako usuniętą (znacznik isDeleted w tabeli Offer)
description: Server marks the offer as deleted.
responses:
200:
401:
description: Offer does not belong to this hotel
404:
description: Offer not found
409:
description: Unable to delete offer
body:
application/json:
example: |
{ "error": "There are still pending reservations for this offer" }
patch:
description: Server modifies offer
body:
application/json:
type: object
properties:
isActive: boolean
offerTitle: string
description: string
offerPreviewPicture: file
offerPictures:
type: array
items: file
example: |
{
"isActive": true,
"offerTitle": "Not so great Offer",
"offerPreviewPicture": "hbUbkjd86jhVG7JFjh",
"description": "",
"offerPictures": []
}
responses:
200:
400:
description: Unable to edit offer
body:
application/json:
example: |
{ "error": "Unable to edit offer" }
401:
description: Offer does not belong to this hotel
404:
description: Not found
/rooms:
get:
description: Lists all rooms related to the hotel offer
is: [pageable]
queryParameters:
roomNumber:
required: false
type: string
description: Optional filter on room number that is applied after the query has finished
example: 13A
responses:
200:
body:
application/json:
type: array
items:
type: object
properties:
roomID: integer
hotelRoomNumber: string
offerID: integer[]
example: |
[
{
"roomID": 5,
"hotelRoomNumber": "13A",
"offerID": [1, 15]
},
{
"roomID": 7,
"hotelRoomNumber": "16",
"offerID": [2, 4, 5]
}
]
401:
description: Offer does not belong to this hotel
404:
description: Offer not found / Room with given roomNumber not found
post:
description: Add a room associated with hotel offer
body:
application/json:
type: integer
description: roomID
example: 21
responses:
200:
400:
description: Unable to add room
body:
application/json:
example: |
{ "error": "Unable to add room" }
401:
description: Offer or room with given ID does not belong to this hotel
404:
description: Offer or room with given ID not found
/{roomID}:
uriParameters:
roomID: integer
delete:
description: Removes room from the offer
responses:
200:
401:
description: Offer or room with given ID does not belong to this hotel
404:
description: Offer or room not found
#--------------------------------------------------------------------------------------------------------
#-----------------------------------------------ROOMS----------------------------------------------------
#--------------------------------------------------------------------------------------------------------
/rooms:
get:
is: [pageable]
description: Lists all rooms
queryParameters:
roomNumber:
required: false
type: string
description: Optional filter on room number that is applied after the query has finished
example: 13A
responses:
200:
body:
application/json:
type: array
items:
type: object
properties:
roomID: integer
hotelRoomNumber: string
offerID: integer[]
example: |
[
{
"roomID": 5,
"hotelRoomNumber": "13A",
"offerID": [1, 15, 28]
},
{
"roomID": 7,
"hotelRoomNumber": "16",
"offerID": [3, 4, 7]
}
]
404:
description: Room with given roomNumber not found
post:
description: Add a room not associated with any offer (HotelRoom table)
body:
application/json:
type: string
description: hotelRoomNumber
example: "12F"
responses:
200:
description: Room added successfully
body:
application/json:
type: integer
description: roomID
example: 14
400:
description: Unable to add room
body:
application/json:
example: |
{ "error": "Unable to add room" }
409:
description: Room with given number already exists
/{roomID}:
uriParameters:
roomID: integer
delete:
#Usuwanie polega na sprawdzeniu czy w systemie są jeszcze nie zrealizowane rezerwacje w ramach tego pokoju.
#Przenosimy rezerwacje do innych pokoi zebranych w ramach tej samej oferty (ZAWSZE).
#Jeśli rezerwacji nie da się przenieść do innych pokoi w ramach tej samej oferty - zwracamy błąd 409 i nie podejmujemy żadnych działań.
#Jeśli rezerwacje da się przenieść lub nie ma żadnych rezerwacji - we wszystkich rezerwacjach (tabela z rezerwacjami), które wskazują na rozpatrywany pokój
#zmieniamy pokój na NULL (należy rozwiązać problem ze spójnością referencyjną) i usuwamy pokój (tabela HotelRoom).
description: Deletes room with given ID. (entry in HotelRoom table is deleted)
responses:
200:
401:
description: Room does not belong to this hotel
404:
description: Room not found
409:
body:
application/json:
description: Unable to delete room
example: |
{
"error": "There are still pending reservations for this room that cannot be moved"
}
#--------------------------------------------------------------------------------------------------------
#--------------------------------------------RESERVATIONS------------------------------------------------
#--------------------------------------------------------------------------------------------------------
/reservations:
get:
description: fetches current (and future) reservations made by clients and information regarding these clients
is: [pageable]
queryParameters:
currentOnly:
required: false
type: boolean
description: get reservations that are currently underway or all reservations (including ones that begin in the future)
roomID:
required: false
type: integer
description: get reservations connected with room with ID equal to roomID parameter
responses:
200:
body:
application/json:
description: Returns an array of objects containing reservation and client information related to a hotel room reservation
type: reservationObject[]
403:
description: Room with ID equal to roomID does not belong to the hotel
404:
body:
application/json:
description: An error containing message describing the type of error
example: |
{
"error": "Room with ID equal to roomID parameter does not exist"
}
#--------------------------------------------------------------------------------------------------------
#-------------------------------------------HotelInfo----------------------------------------------------
#--------------------------------------------------------------------------------------------------------
/hotelInfo:
get:
description: Show info about hotel
responses:
200:
body:
application/json:
type: object
properties:
country: string
city: string
hotelName: string
hotelDesc: string
hotelPreviewPicture: file
hotelPictures: file[]
example: |
{
"country": "Poland",
"city": "Warsaw",
"hotelName": "Novotel",
"hotelDesc": "Live Limitless",
"hotelPreviewPicture": "",
"hotelPictures": []
}
patch:
description: Update info about hotel
body:
application/json:
type: object
properties:
hotelName: string
hotelDesc: string
hotelPreviewPicture: file
hotelPictures: file[]
example: |
{
"hotelName": "Novotel",
"hotelDesc": "Live Limitless",
"hotelPreviewPicture": "",
"hotelPictures": []
}
responses:
200:
400:
description: Unable to add offer
body:
application/json:
example: |
{ "error": "Unable to add offer" }