Bug 20944: OpenAPI spec for /patrons/{patron_id}/account/credits
authorTomas Cohen Arazi <tomascohen@theke.io>
Tue, 10 Jul 2018 17:53:47 +0000 (14:53 -0300)
committerNick Clemens <nick@bywatersolutions.com>
Fri, 31 Aug 2018 12:46:59 +0000 (12:46 +0000)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

api/v1/swagger/definitions.json
api/v1/swagger/definitions/patron_account_credit.json [new file with mode: 0644]
api/v1/swagger/paths.json
api/v1/swagger/paths/patrons_account.json

index b9c0a29..6509432 100644 (file)
@@ -17,6 +17,9 @@
   "patron": {
     "$ref": "definitions/patron.json"
   },
+  "patron_account_credit": {
+    "$ref": "definitions/patron_account_credit.json"
+  },
   "patron_balance": {
     "$ref": "definitions/patron_balance.json"
   },
diff --git a/api/v1/swagger/definitions/patron_account_credit.json b/api/v1/swagger/definitions/patron_account_credit.json
new file mode 100644 (file)
index 0000000..ddb71e3
--- /dev/null
@@ -0,0 +1,39 @@
+{
+  "type": "object",
+  "properties": {
+    "credit_type": {
+      "type": "string",
+      "description": "Type of credit ('credit', 'forgiven', 'lost_item_return', 'payment', 'writeoff' )"
+    },
+    "amount": {
+      "type": "number",
+      "minimum": 0,
+      "description": "Credit amount"
+    },
+    "account_lines_ids": {
+        "type": "array",
+        "items": {
+            "type": "integer"
+        },
+        "description": "List of account line ids the credit goes against (optional)"
+    },
+    "payment_type": {
+        "type": "string",
+        "description":  "Payment type (only applies when credit_type=payment)"
+    },
+    "date": {
+      "type": "string",
+      "format": "date",
+      "description": "Date the credit was recorded (optional)"
+    },
+    "description": {
+      "type": "string",
+      "description": "Description"
+    },
+    "note": {
+      "type": "string",
+      "description": "Internal note"
+    }
+  },
+  "required": [ "amount" ]
+}
index fb5f7a3..c9d8e88 100644 (file)
@@ -29,6 +29,9 @@
   "/patrons/{patron_id}/account": {
     "$ref": "paths/patrons_account.json#/~1patrons~1{patron_id}~1account"
   },
+  "/patrons/{patron_id}/account/credits": {
+    "$ref": "paths/patrons_account.json#/~1patrons~1{patron_id}~1account~1credits"
+  },
   "/illrequests": {
     "$ref": "paths/illrequests.json#/~1illrequests"
   }
index 5a2a0d0..8ad88f0 100644 (file)
         }
       }
     }
+  },
+  "/patrons/{patron_id}/account/credits": {
+    "post": {
+      "x-mojo-to": "Patrons::Account#add_credit",
+      "operationId": "addPatronCredit",
+      "tags": [
+        "patron"
+      ],
+      "parameters": [
+        {
+          "$ref": "../parameters.json#/patron_id_pp"
+        },
+        {
+          "name": "body",
+          "in": "body",
+          "description": "A JSON object containing credit information",
+          "required": true,
+          "schema": {
+            "$ref": "../definitions.json#/patron_account_credit"
+          }
+        }
+      ],
+      "produces": [
+        "application/json"
+      ],
+      "responses": {
+        "200": {
+          "description": "Credit added",
+          "schema": {
+            "type": "object"
+          }
+        },
+        "401": {
+          "description": "Authentication required",
+          "schema": {
+            "$ref": "../definitions.json#/error"
+          }
+        },
+        "403": {
+          "description": "Access forbidden",
+          "schema": {
+            "$ref": "../definitions.json#/error"
+          }
+        },
+        "404": {
+          "description": "Patron 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": {
+          "updatecharges": "remaining_permissions"
+        }
+      }
+    }
   }
 }