Bug 22206: OpenAPI spec
[koha.git] / api / v1 / swagger / paths / holds.json
index adf1178..2dea98c 100644 (file)
@@ -1,69 +1,62 @@
 {
   "/holds": {
     "get": {
-      "x-mojo-to": "Hold#list",
+      "x-mojo-to": "Holds#list",
       "operationId": "listHolds",
       "tags": ["patrons", "holds"],
       "parameters": [
         {
-          "name": "reserve_id",
+          "name": "hold_id",
           "in": "query",
           "description": "Internal reserve identifier",
           "type": "integer"
         },
         {
-          "$ref": "../parameters.json#/borrowernumberQueryParam"
-        },
-        {
-          "name": "reservedate",
+          "name": "patron_id",
           "in": "query",
-          "description": "Reserve date",
-          "type": "string"
-        },
-        {
-          "name": "biblionumber",
-          "in": "query",
-          "description": "Internal biblio identifier",
+          "description": "Internal patron identifier",
           "type": "integer"
         },
         {
-          "name": "branchcode",
+          "name": "hold_date",
           "in": "query",
-          "description": "Branch code",
-          "type": "string"
+          "description": "Hold",
+          "type": "string",
+          "format": "date"
         },
         {
-          "name": "notificationdate",
+          "name": "biblio_id",
           "in": "query",
-          "description": "Notification date",
-          "type": "string"
+          "description": "Internal biblio identifier",
+          "type": "integer"
         },
         {
-          "name": "reminderdate",
+          "name": "pickup_library_id",
           "in": "query",
-          "description": "Reminder date",
+          "description": "Internal library identifier for the pickup library",
           "type": "string"
         },
         {
-          "name": "cancellationdate",
+          "name": "cancelation_date",
           "in": "query",
-          "description": "Cancellation date",
-          "type": "string"
+          "description": "The date the hold was cancelled",
+          "type": "string",
+          "format": "date"
         },
         {
-          "name": "reservenotes",
+          "name": "notes",
           "in": "query",
-          "description": "Reserve notes",
+          "description": "Notes related to this hold",
           "type": "string"
         },
         {
           "name": "priority",
           "in": "query",
-          "description": "Priority",
+          "description": "Where in the queue the patron sits",
           "type": "integer"
         },
         {
-          "name": "found",
+          "name": "status",
           "in": "query",
           "description": "Found status",
           "type": "string"
           "type": "string"
         },
         {
-          "name": "itemnumber",
+          "name": "item_id",
           "in": "query",
           "description": "Internal item identifier",
           "type": "integer"
         },
         {
-          "name": "waitingdate",
+          "name": "waiting_date",
           "in": "query",
           "description": "Date the item was marked as waiting for the patron",
           "type": "string"
         },
         {
-          "name": "expirationdate",
+          "name": "expiration_date",
           "in": "query",
           "description": "Date the hold expires",
           "type": "string"
         },
         {
-          "name": "lowestPriority",
+          "name": "lowest_priority",
           "in": "query",
           "description": "Lowest priority",
-          "type": "integer"
+          "type": "boolean"
         },
         {
-          "name": "suspend",
+          "name": "suspended",
           "in": "query",
           "description": "Suspended",
-          "type": "integer"
+          "type": "boolean"
         },
         {
-          "name": "suspend_until",
+          "name": "suspended_until",
           "in": "query",
           "description": "Suspended until",
           "type": "string"
         }
       },
       "x-koha-authorization": {
-        "allow-owner": true,
-        "allow-guarantor": true,
         "permissions": {
-          "borrowers": "1"
+          "borrowers": "edit_borrowers"
         }
       }
     },
     "post": {
-      "x-mojo-to": "Hold#add",
+      "x-mojo-to": "Holds#add",
       "operationId": "addHold",
       "tags": ["patrons", "holds"],
       "parameters": [{
           "schema": {
             "type": "object",
             "properties": {
-              "borrowernumber": {
-                "description": "Borrower internal identifier",
+              "patron_id": {
+                "description": "Internal patron identifier",
                 "type": "integer"
               },
-              "biblionumber": {
-                "description": "Biblio internal identifier",
-                "type": "integer"
+              "biblio_id": {
+                "description": "Internal biblio identifier",
+                "type": [ "integer", "null" ]
               },
-              "itemnumber": {
-                "description": "Item internal identifier",
-                "type": "integer"
+              "item_id": {
+                "description": "Internal item identifier",
+                "type": [ "integer", "null" ]
               },
-              "branchcode": {
-                "description": "Pickup location",
+              "pickup_library_id": {
+                "description": "Internal library identifier for the pickup library",
                 "type": "string"
               },
-              "expirationdate": {
+              "expiration_date": {
                 "description": "Hold end date",
-                "type": "string",
+                "type": ["string", "null"],
                 "format": "date"
               },
-              "itemtype": {
+              "notes": {
+                "description": "Notes related to this hold",
+                "type": [ "string", "null" ]
+              },
+              "item_type": {
                 "description": "Limit hold on one itemtype (ignored for item-level holds)",
-                "type": "string"
+                "type": [ "string", "null" ]
               }
-            }
+            },
+            "required": [ "patron_id", "pickup_library_id" ]
           }
         }
       ],
         }
       },
       "x-koha-authorization": {
-        "allow-owner": true,
         "permissions": {
           "reserveforothers": "1"
         }
       }
     }
   },
-  "/holds/{reserve_id}": {
+  "/holds/{hold_id}": {
     "put": {
-      "x-mojo-to": "Hold#edit",
+      "x-mojo-to": "Holds#edit",
       "operationId": "editHold",
       "tags": ["holds"],
       "parameters": [{
-          "$ref": "../parameters.json#/holdIdPathParam"
+          "$ref": "../parameters.json#/hold_id_pp"
         }, {
           "name": "body",
           "in": "body",
         }
       },
       "x-koha-authorization": {
-        "allow-owner": true,
-        "allow-guarantor": true,
         "permissions": {
           "reserveforothers": "1"
         }
       }
     },
     "delete": {
-      "x-mojo-to": "Hold#delete",
+      "x-mojo-to": "Holds#delete",
       "operationId": "deleteHold",
       "tags": ["holds"],
       "parameters": [{
-          "$ref": "../parameters.json#/holdIdPathParam"
+          "$ref": "../parameters.json#/hold_id_pp"
         }
       ],
       "produces": ["application/json"],
         }
       }
     }
+  },
+  "/holds/{hold_id}/suspension": {
+    "post": {
+      "x-mojo-to": "Holds#suspend",
+      "operationId": "suspendHold",
+      "tags": ["holds"],
+      "parameters": [{
+          "$ref": "../parameters.json#/hold_id_pp"
+        }, {
+          "name": "body",
+          "in": "body",
+          "description": "A JSON object containing fields to modify",
+          "required": false,
+          "schema": {
+            "type": "object",
+            "properties": {
+              "expiration_date": {
+                "description": "Date the hold suspension expires",
+                "type": "string",
+                "format": "date"
+              }
+            }
+          }
+        }
+      ],
+      "consumes": ["application/json"],
+      "produces": ["application/json"],
+      "responses": {
+        "201": {
+          "description": "Hold suspended"
+        },
+        "400": {
+          "description": "Missing or wrong parameters",
+          "schema": {
+            "$ref": "../definitions.json#/error"
+          }
+        },
+        "401": {
+          "description": "Authentication required",
+          "schema": {
+            "$ref": "../definitions.json#/error"
+          }
+        },
+        "403": {
+          "description": "Hold not allowed",
+          "schema": {
+            "$ref": "../definitions.json#/error"
+          }
+        },
+        "404": {
+          "description": "Hold not found",
+          "schema": {
+            "$ref": "../definitions.json#/error"
+          }
+        },
+        "500": {
+          "description": "Internal server error",
+          "schema": {
+            "$ref": "../definitions.json#/error"
+          }
+        },
+        "503": {
+          "description": "Under maintenance",
+          "schema": {
+            "$ref": "../definitions.json#/error"
+          }
+        }
+      },
+      "x-koha-authorization": {
+        "permissions": {
+          "reserveforothers": "1"
+        }
+      }
+    },
+    "delete": {
+      "x-mojo-to": "Holds#resume",
+      "operationId": "resumeHold",
+      "tags": ["holds"],
+      "parameters": [
+        {
+          "$ref": "../parameters.json#/hold_id_pp"
+        }
+      ],
+      "consumes": ["application/json"],
+      "produces": ["application/json"],
+      "responses": {
+        "204": {
+          "description": "Hold resumed"
+        },
+        "400": {
+          "description": "Missing or wrong parameters",
+          "schema": {
+            "$ref": "../definitions.json#/error"
+          }
+        },
+        "401": {
+          "description": "Authentication required",
+          "schema": {
+            "$ref": "../definitions.json#/error"
+          }
+        },
+        "403": {
+          "description": "Hold not allowed",
+          "schema": {
+            "$ref": "../definitions.json#/error"
+          }
+        },
+        "404": {
+          "description": "Hold not found",
+          "schema": {
+            "$ref": "../definitions.json#/error"
+          }
+        },
+        "500": {
+          "description": "Internal server error",
+          "schema": {
+            "$ref": "../definitions.json#/error"
+          }
+        },
+        "503": {
+          "description": "Under maintenance",
+          "schema": {
+            "$ref": "../definitions.json#/error"
+          }
+        }
+      },
+      "x-koha-authorization": {
+        "permissions": {
+          "reserveforothers": "1"
+        }
+      }
+    }
   }
 }