From dcf454e726d44495084654e77ba612166ec39852 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 10 Jul 2018 14:53:47 -0300 Subject: [PATCH] Bug 20944: OpenAPI spec for /patrons/{patron_id}/account/credits Signed-off-by: Martin Renvoize Signed-off-by: Josef Moravec --- api/v1/swagger/definitions.json | 3 + .../swagger/definitions/patron_account_credit.json | 39 ++++++++++++ api/v1/swagger/paths.json | 3 + api/v1/swagger/paths/patrons_account.json | 69 ++++++++++++++++++++++ 4 files changed, 114 insertions(+) create mode 100644 api/v1/swagger/definitions/patron_account_credit.json diff --git a/api/v1/swagger/definitions.json b/api/v1/swagger/definitions.json index b9c0a29..6509432 100644 --- a/api/v1/swagger/definitions.json +++ b/api/v1/swagger/definitions.json @@ -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 index 0000000..ddb71e3 --- /dev/null +++ b/api/v1/swagger/definitions/patron_account_credit.json @@ -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" ] +} diff --git a/api/v1/swagger/paths.json b/api/v1/swagger/paths.json index fb5f7a3..c9d8e88 100644 --- a/api/v1/swagger/paths.json +++ b/api/v1/swagger/paths.json @@ -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" } diff --git a/api/v1/swagger/paths/patrons_account.json b/api/v1/swagger/paths/patrons_account.json index 5a2a0d0..8ad88f0 100644 --- a/api/v1/swagger/paths/patrons_account.json +++ b/api/v1/swagger/paths/patrons_account.json @@ -61,5 +61,74 @@ } } } + }, + "/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" + } + } + } } } -- 2.1.4