From 507a1e4dbe6a61e93b8fcba29e077704229a622c Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Mon, 13 Feb 2017 15:40:33 +0200 Subject: [PATCH] Bug 18013: Add patronstatus to Swagger This patch adds the Swagger definition for patronstatus. https://bugs.koha-community.org/show_bug.cgi?id=18103 --- api/v1/swagger/definitions.json | 3 ++ api/v1/swagger/definitions/patronstatus.json | 79 ++++++++++++++++++++++++++++ api/v1/swagger/paths.json | 3 ++ api/v1/swagger/paths/patrons.json | 46 ++++++++++++++++ 4 files changed, 131 insertions(+) create mode 100644 api/v1/swagger/definitions/patronstatus.json diff --git a/api/v1/swagger/definitions.json b/api/v1/swagger/definitions.json index 3967876..85f180b 100644 --- a/api/v1/swagger/definitions.json +++ b/api/v1/swagger/definitions.json @@ -14,6 +14,9 @@ "patron": { "$ref": "definitions/patron.json" }, + "patronstatus": { + "$ref": "definitions/patronstatus.json" + }, "holds": { "$ref": "definitions/holds.json" }, diff --git a/api/v1/swagger/definitions/patronstatus.json b/api/v1/swagger/definitions/patronstatus.json new file mode 100644 index 0000000..c71e814 --- /dev/null +++ b/api/v1/swagger/definitions/patronstatus.json @@ -0,0 +1,79 @@ +{ + "type": "object", + "allOf": [ + { "$ref": "../definitions.json#/patron" }, + { + "type": "object", + "properties": { + "blocks": { + "type": "object", + "properties": { + "Patron::CardExpired": { + "description": "Patron's card has been expired.", + "type": "object", + "properties": { + "expiration_date": { + "type": ["string", "null"] + } + } + }, + "Patron::CardLost": { + "description": "Patron's card has been marked as lost.", + "type": "object", + "properties": {} + }, + "Patron::Debarred": { + "description": "Patron is debarred.", + "type": "object", + "properties": { + "expiration_date": { + "type": ["string", "null"] + }, + "comment": { + "type": ["string", "null"] + } + } + }, + "Patron::DebarredOverdue": { + "description": "Patron has overdues and is debarred.", + "type": "object", + "properties": { + "number_of_overdues": { + "type": ["integer", "null"] + } + } + }, + "Patron::Debt": { + "description": "Patron's debts exceed maximum allowed amount.", + "type": "object", + "properties": { + "max_outstanding":{ + "type": ["number", "null"] + }, + "current_outstanding": { + "type": ["number", "null"] + } + } + }, + "Patron::DebtGuarantees": { + "description": "Patron's guarantees' debts exceed maximum allowed amount.", + "type": "object", + "properties": { + "max_outstanding":{ + "type": ["number", "null"] + }, + "current_outstanding": { + "type": ["number", "null"] + } + } + }, + "Patron::GoneNoAddress": { + "type": "object", + "properties": {} + } + } + } + } + } + ] +} diff --git a/api/v1/swagger/paths.json b/api/v1/swagger/paths.json index 0a914c2..ad52249 100644 --- a/api/v1/swagger/paths.json +++ b/api/v1/swagger/paths.json @@ -31,5 +31,8 @@ }, "/patrons/{borrowernumber}": { "$ref": "paths/patrons.json#/~1patrons~1{borrowernumber}" + }, + "/patrons/{borrowernumber}/status": { + "$ref": "paths/patrons.json#/~1patrons~1{borrowernumber}~1status" } } diff --git a/api/v1/swagger/paths/patrons.json b/api/v1/swagger/paths/patrons.json index 67632e1..bde2b68 100644 --- a/api/v1/swagger/paths/patrons.json +++ b/api/v1/swagger/paths/patrons.json @@ -69,5 +69,51 @@ } } } + }, + "/patrons/{borrowernumber}/status": { + "get": { + "operationId": "getstatusPatron", + "tags": ["patrons"], + "parameters": [{ + "$ref": "../parameters.json#/borrowernumberPathParam" + } + ], + "produces": [ + "application/json" + ], + "responses": { + "200": { + "description": "A patron", + "schema": { + "$ref": "../definitions.json#/patronstatus" + } + }, + "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" + } + } + }, + "x-koha-authorization": { + "allow-owner": true, + "allow-guarantor": true, + "permissions": { + "borrowers": "1" + } + } + } } } -- 1.9.1