Bug 23517: Add a spec for PUT /holds/{hold_id}/priority
[koha.git] / api / v1 / swagger / paths / holds.json
1 {
2   "/holds": {
3     "get": {
4       "x-mojo-to": "Holds#list",
5       "operationId": "listHolds",
6       "tags": ["patrons", "holds"],
7       "parameters": [
8         {
9           "name": "hold_id",
10           "in": "query",
11           "description": "Internal reserve identifier",
12           "type": "integer"
13         },
14         {
15           "name": "patron_id",
16           "in": "query",
17           "description": "Internal patron identifier",
18           "type": "integer"
19         },
20         {
21           "name": "hold_date",
22           "in": "query",
23           "description": "Hold",
24           "type": "string",
25           "format": "date"
26         },
27         {
28           "name": "biblio_id",
29           "in": "query",
30           "description": "Internal biblio identifier",
31           "type": "integer"
32         },
33         {
34           "name": "pickup_library_id",
35           "in": "query",
36           "description": "Internal library identifier for the pickup library",
37           "type": "string"
38         },
39         {
40           "name": "cancelation_date",
41           "in": "query",
42           "description": "The date the hold was cancelled",
43           "type": "string",
44           "format": "date"
45         },
46         {
47           "name": "notes",
48           "in": "query",
49           "description": "Notes related to this hold",
50           "type": "string"
51         },
52         {
53           "name": "priority",
54           "in": "query",
55           "description": "Where in the queue the patron sits",
56           "type": "integer"
57         },
58         {
59           "name": "status",
60           "in": "query",
61           "description": "Found status",
62           "type": "string"
63         },
64         {
65           "name": "timestamp",
66           "in": "query",
67           "description": "Time of latest update",
68           "type": "string"
69         },
70         {
71           "name": "item_id",
72           "in": "query",
73           "description": "Internal item identifier",
74           "type": "integer"
75         },
76         {
77           "name": "waiting_date",
78           "in": "query",
79           "description": "Date the item was marked as waiting for the patron",
80           "type": "string"
81         },
82         {
83           "name": "expiration_date",
84           "in": "query",
85           "description": "Date the hold expires",
86           "type": "string"
87         },
88         {
89           "name": "lowest_priority",
90           "in": "query",
91           "description": "Lowest priority",
92           "type": "boolean"
93         },
94         {
95           "name": "suspended",
96           "in": "query",
97           "description": "Suspended",
98           "type": "boolean"
99         },
100         {
101           "name": "suspended_until",
102           "in": "query",
103           "description": "Suspended until",
104           "type": "string"
105         },
106         {
107             "$ref": "../parameters.json#/match"
108         },
109         {
110             "$ref": "../parameters.json#/order_by"
111         },
112         {
113             "$ref": "../parameters.json#/page"
114         },
115         {
116             "$ref": "../parameters.json#/per_page"
117         }
118       ],
119       "produces": ["application/json"],
120       "responses": {
121         "200": {
122           "description": "A list of holds",
123           "schema": {
124             "$ref": "../definitions.json#/holds"
125           }
126         },
127         "401": {
128           "description": "Authentication required",
129           "schema": {
130             "$ref": "../definitions.json#/error"
131           }
132         },
133         "403": {
134           "description": "Hold not allowed",
135           "schema": {
136             "$ref": "../definitions.json#/error"
137           }
138         },
139         "404": {
140           "description": "Borrower not found",
141           "schema": {
142             "$ref": "../definitions.json#/error"
143           }
144         },
145         "500": {
146           "description": "Internal server error",
147           "schema": {
148             "$ref": "../definitions.json#/error"
149           }
150         },
151         "503": {
152           "description": "Under maintenance",
153           "schema": {
154             "$ref": "../definitions.json#/error"
155           }
156         }
157       },
158       "x-koha-authorization": {
159         "permissions": {
160           "borrowers": "edit_borrowers"
161         }
162       }
163     },
164     "post": {
165       "x-mojo-to": "Holds#add",
166       "operationId": "addHold",
167       "tags": ["patrons", "holds"],
168       "parameters": [{
169           "name": "body",
170           "in": "body",
171           "description": "A JSON object containing informations about the new hold",
172           "required": true,
173           "schema": {
174             "type": "object",
175             "properties": {
176               "patron_id": {
177                 "description": "Internal patron identifier",
178                 "type": "integer"
179               },
180               "biblio_id": {
181                 "description": "Internal biblio identifier",
182                 "type": [ "integer", "null" ]
183               },
184               "item_id": {
185                 "description": "Internal item identifier",
186                 "type": [ "integer", "null" ]
187               },
188               "pickup_library_id": {
189                 "description": "Internal library identifier for the pickup library",
190                 "type": "string"
191               },
192               "expiration_date": {
193                 "description": "Hold end date",
194                 "type": ["string", "null"],
195                 "format": "date"
196               },
197               "notes": {
198                 "description": "Notes related to this hold",
199                 "type": [ "string", "null" ]
200               },
201               "item_type": {
202                 "description": "Limit hold on one itemtype (ignored for item-level holds)",
203                 "type": [ "string", "null" ]
204               }
205             },
206             "required": [ "patron_id", "pickup_library_id" ]
207           }
208         }
209       ],
210       "consumes": ["application/json"],
211       "produces": ["application/json"],
212       "responses": {
213         "201": {
214           "description": "Created hold",
215           "schema": {
216             "$ref": "../definitions.json#/hold"
217           }
218         },
219         "400": {
220           "description": "Missing or wrong parameters",
221           "schema": {
222             "$ref": "../definitions.json#/error"
223           }
224         },
225         "401": {
226           "description": "Authentication required",
227           "schema": {
228             "$ref": "../definitions.json#/error"
229           }
230         },
231         "403": {
232           "description": "Hold not allowed",
233           "schema": {
234             "$ref": "../definitions.json#/error"
235           }
236         },
237         "404": {
238           "description": "Borrower not found",
239           "schema": {
240             "$ref": "../definitions.json#/error"
241           }
242         },
243         "500": {
244           "description": "Internal server error",
245           "schema": {
246             "$ref": "../definitions.json#/error"
247           }
248         },
249         "503": {
250           "description": "Under maintenance",
251           "schema": {
252             "$ref": "../definitions.json#/error"
253           }
254         }
255       },
256       "x-koha-authorization": {
257         "permissions": {
258           "reserveforothers": "1"
259         }
260       }
261     }
262   },
263   "/holds/{hold_id}": {
264     "put": {
265       "x-mojo-to": "Holds#edit",
266       "operationId": "editHold",
267       "tags": ["holds"],
268       "parameters": [{
269           "$ref": "../parameters.json#/hold_id_pp"
270         }, {
271           "name": "body",
272           "in": "body",
273           "description": "A JSON object containing fields to modify",
274           "required": true,
275           "schema": {
276             "type": "object",
277             "properties": {
278               "priority": {
279                 "description": "Position in waiting queue",
280                 "type": "integer",
281                 "minimum": 1
282               },
283               "branchcode": {
284                 "description": "Pickup location",
285                 "type": "string"
286               },
287               "suspend_until": {
288                 "description": "Suspend until",
289                 "type": "string",
290                 "format": "date"
291               }
292             }
293           }
294         }
295       ],
296       "consumes": ["application/json"],
297       "produces": ["application/json"],
298       "responses": {
299         "200": {
300           "description": "Updated hold",
301           "schema": {
302             "$ref": "../definitions.json#/hold"
303           }
304         },
305         "400": {
306           "description": "Missing or wrong parameters",
307           "schema": {
308             "$ref": "../definitions.json#/error"
309           }
310         },
311         "401": {
312           "description": "Authentication required",
313           "schema": {
314             "$ref": "../definitions.json#/error"
315           }
316         },
317         "403": {
318           "description": "Hold not allowed",
319           "schema": {
320             "$ref": "../definitions.json#/error"
321           }
322         },
323         "404": {
324           "description": "Hold not found",
325           "schema": {
326             "$ref": "../definitions.json#/error"
327           }
328         },
329         "500": {
330           "description": "Internal server error",
331           "schema": {
332             "$ref": "../definitions.json#/error"
333           }
334         },
335         "503": {
336           "description": "Under maintenance",
337           "schema": {
338             "$ref": "../definitions.json#/error"
339           }
340         }
341       },
342       "x-koha-authorization": {
343         "permissions": {
344           "reserveforothers": "1"
345         }
346       }
347     },
348     "delete": {
349       "x-mojo-to": "Holds#delete",
350       "operationId": "deleteHold",
351       "tags": ["holds"],
352       "parameters": [{
353           "$ref": "../parameters.json#/hold_id_pp"
354         }
355       ],
356       "produces": ["application/json"],
357       "responses": {
358         "200": {
359           "description": "Successful deletion",
360           "schema": {
361             "type": "object"
362           }
363         },
364         "401": {
365           "description": "Authentication required",
366           "schema": {
367             "$ref": "../definitions.json#/error"
368           }
369         },
370         "403": {
371           "description": "Hold not allowed",
372           "schema": {
373             "$ref": "../definitions.json#/error"
374           }
375         },
376         "404": {
377           "description": "Hold not found",
378           "schema": {
379             "$ref": "../definitions.json#/error"
380           }
381         },
382         "500": {
383           "description": "Internal server error",
384           "schema": {
385             "$ref": "../definitions.json#/error"
386           }
387         },
388         "503": {
389           "description": "Under maintenance",
390           "schema": {
391             "$ref": "../definitions.json#/error"
392           }
393         }
394       },
395       "x-koha-authorization": {
396         "permissions": {
397           "reserveforothers": "1"
398         }
399       }
400     }
401   },
402   "/holds/{hold_id}/priority": {
403     "put": {
404       "x-mojo-to": "Holds#update_priority",
405       "operationId": "updateHoldPriority",
406       "tags": [
407         "biblios",
408         "holds"
409       ],
410       "parameters": [
411         {
412           "$ref": "../parameters.json#/hold_id_pp"
413         },
414         {
415           "name": "body",
416           "in": "body",
417           "description": "An integer representing the new priority to be set for the hold",
418           "required": true,
419           "schema": {
420             "type": "integer"
421           }
422         }
423       ],
424       "produces": [
425         "application/json"
426       ],
427       "responses": {
428         "200": {
429           "description": "The new priority value for the hold",
430           "schema": {
431             "type": "integer"
432           }
433         },
434         "401": {
435           "description": "Authentication required",
436           "schema": {
437             "$ref": "../definitions.json#/error"
438           }
439         },
440         "403": {
441           "description": "Access forbidden",
442           "schema": {
443             "$ref": "../definitions.json#/error"
444           }
445         },
446         "404": {
447           "description": "Biblio not found",
448           "schema": {
449             "$ref": "../definitions.json#/error"
450           }
451         },
452         "409": {
453           "description": "Unable to perform action on biblio",
454           "schema": {
455             "$ref": "../definitions.json#/error"
456           }
457         },
458         "500": {
459           "description": "Internal error",
460           "schema": {
461             "$ref": "../definitions.json#/error"
462           }
463         },
464         "503": {
465           "description": "Under maintenance",
466           "schema": {
467             "$ref": "../definitions.json#/error"
468           }
469         }
470       },
471       "x-koha-authorization": {
472         "permissions": {
473           "reserveforothers": "modify_holds_priority"
474         }
475       }
476     }
477   },
478   "/holds/{hold_id}/suspension": {
479     "post": {
480       "x-mojo-to": "Holds#suspend",
481       "operationId": "suspendHold",
482       "tags": ["holds"],
483       "parameters": [{
484           "$ref": "../parameters.json#/hold_id_pp"
485         }, {
486           "name": "body",
487           "in": "body",
488           "description": "A JSON object containing fields to modify",
489           "required": false,
490           "schema": {
491             "type": "object",
492             "properties": {
493               "end_date": {
494                 "description": "Date the hold suspension expires",
495                 "type": "string",
496                 "format": "date"
497               }
498             }
499           }
500         }
501       ],
502       "consumes": ["application/json"],
503       "produces": ["application/json"],
504       "responses": {
505         "201": {
506           "description": "Hold suspended"
507         },
508         "400": {
509           "description": "Missing or wrong parameters",
510           "schema": {
511             "$ref": "../definitions.json#/error"
512           }
513         },
514         "401": {
515           "description": "Authentication required",
516           "schema": {
517             "$ref": "../definitions.json#/error"
518           }
519         },
520         "403": {
521           "description": "Hold not allowed",
522           "schema": {
523             "$ref": "../definitions.json#/error"
524           }
525         },
526         "404": {
527           "description": "Hold not found",
528           "schema": {
529             "$ref": "../definitions.json#/error"
530           }
531         },
532         "500": {
533           "description": "Internal server error",
534           "schema": {
535             "$ref": "../definitions.json#/error"
536           }
537         },
538         "503": {
539           "description": "Under maintenance",
540           "schema": {
541             "$ref": "../definitions.json#/error"
542           }
543         }
544       },
545       "x-koha-authorization": {
546         "permissions": {
547           "reserveforothers": "1"
548         }
549       }
550     },
551     "delete": {
552       "x-mojo-to": "Holds#resume",
553       "operationId": "resumeHold",
554       "tags": ["holds"],
555       "parameters": [
556         {
557           "$ref": "../parameters.json#/hold_id_pp"
558         }
559       ],
560       "consumes": ["application/json"],
561       "produces": ["application/json"],
562       "responses": {
563         "204": {
564           "description": "Hold resumed"
565         },
566         "400": {
567           "description": "Missing or wrong parameters",
568           "schema": {
569             "$ref": "../definitions.json#/error"
570           }
571         },
572         "401": {
573           "description": "Authentication required",
574           "schema": {
575             "$ref": "../definitions.json#/error"
576           }
577         },
578         "403": {
579           "description": "Hold not allowed",
580           "schema": {
581             "$ref": "../definitions.json#/error"
582           }
583         },
584         "404": {
585           "description": "Hold not found",
586           "schema": {
587             "$ref": "../definitions.json#/error"
588           }
589         },
590         "500": {
591           "description": "Internal server error",
592           "schema": {
593             "$ref": "../definitions.json#/error"
594           }
595         },
596         "503": {
597           "description": "Under maintenance",
598           "schema": {
599             "$ref": "../definitions.json#/error"
600           }
601         }
602       },
603       "x-koha-authorization": {
604         "permissions": {
605           "reserveforothers": "1"
606         }
607       }
608     }
609   }
610 }