Bugzilla – Attachment 99021 Details for
Bug 24609
Add routes for updating checkouts
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24609: Create PUT /checkouts/{checkout_id}
Bug-24609-Create-PUT-checkoutscheckoutid.patch (text/plain), 5.58 KB, created by
Lisette Scheer
on 2020-02-14 19:33:58 UTC
(
hide
)
Description:
Bug 24609: Create PUT /checkouts/{checkout_id}
Filename:
MIME Type:
Creator:
Lisette Scheer
Created:
2020-02-14 19:33:58 UTC
Size:
5.58 KB
patch
obsolete
>From 9b69542312373bed377a9f303e0e90f7b052d230 Mon Sep 17 00:00:00 2001 >From: Andrew Isherwood <andrew.isherwood@ptfs-europe.com> >Date: Fri, 7 Feb 2020 15:21:49 +0000 >Subject: [PATCH] Bug 24609: Create PUT /checkouts/{checkout_id} > >This patch creates a PUT /checkouts/{checkout_id} API route enabling >checkouts to be updated > >Signed-off-by: Lisette Scheer <lisettes@latahlibrary.org> >--- > Koha/REST/V1/Checkouts.pm | 43 ++++++++++++++++++++++++++++++++ > api/v1/swagger/definitions/checkout.json | 14 +++++++++++ > api/v1/swagger/paths/checkouts.json | 39 +++++++++++++++++++++++++++++ > 3 files changed, 96 insertions(+) > >diff --git a/Koha/REST/V1/Checkouts.pm b/Koha/REST/V1/Checkouts.pm >index c3ae141e67..9bd5221f19 100644 >--- a/Koha/REST/V1/Checkouts.pm >+++ b/Koha/REST/V1/Checkouts.pm >@@ -227,4 +227,47 @@ sub allows_renewal { > ); > } > >+=head3 update >+ >+Update a checkout >+ >+=cut >+ >+sub update { >+ my $c = shift->openapi->valid_input or return; >+ >+ my $checkout_id = $c->validation->param('checkout_id'); >+ my $checkout = Koha::Checkouts->find( $checkout_id ); >+ >+ unless ($checkout) { >+ return $c->render( >+ status => 404, >+ openapi => { error => "Checkout doesn't exist" } >+ ); >+ } >+ >+ return try { >+ my $params = $c->req->json; >+ $checkout->set_from_api( $params ); >+ $checkout->store(); >+ return $c->render( >+ status => 200, >+ openapi => $checkout->to_api >+ ); >+ } >+ catch { >+ unless ( blessed $_ && $_->can('rethrow') ) { >+ return $c->render( >+ status => 500, >+ openapi => { error => "Something went wrong, check Koha logs for details." } >+ ); >+ } >+ >+ return $c->render( >+ status => 500, >+ openapi => { error => "$_" } >+ ); >+ }; >+} >+ > 1; >diff --git a/api/v1/swagger/definitions/checkout.json b/api/v1/swagger/definitions/checkout.json >index 42b9598843..7088de0c65 100644 >--- a/api/v1/swagger/definitions/checkout.json >+++ b/api/v1/swagger/definitions/checkout.json >@@ -3,13 +3,16 @@ > "properties": { > "checkout_id": { > "type": "integer", >+ "readOnly": true, > "description": "internally assigned checkout identifier" > }, > "patron_id": { >+ "readOnly": true, > "$ref": "../x-primitives.json#/patron_id" > }, > "item_id": { > "type": "integer", >+ "readOnly": true, > "description": "internal identifier of checked out item" > }, > "due_date": { >@@ -19,49 +22,60 @@ > }, > "library_id": { > "type": ["string", "null"], >+ "readOnly": true, > "description": "code of the library the item was checked out" > }, > "checkin_date": { > "type": ["string", "null"], >+ "readOnly": true, > "format": "date-time", > "description": "Date the item was returned" > }, > "last_renewed_date": { > "type": ["string", "null"], >+ "readOnly": true, > "format": "date-time", > "description": "Date the item was last renewed" > }, > "renewals": { > "type": ["integer", "null"], >+ "readOnly": true, > "description": "Number of renewals" > }, > "auto_renew": { > "type": "boolean", >+ "readOnly": true, > "description": "Auto renewal" > }, > "auto_renew_error": { > "type": ["string", "null"], >+ "readOnly": true, > "description": "Auto renewal error" > }, > "timestamp": { > "type": "string", >+ "readOnly": true, > "description": "Last update time" > }, > "checkout_date": { > "type": "string", >+ "readOnly": true, > "format": "date-time", > "description": "Date the item was issued" > }, > "onsite_checkout": { > "type": "boolean", >+ "readOnly": true, > "description": "On site checkout" > }, > "note": { > "type": ["string", "null"], >+ "readOnly": true, > "description": "Issue note text" > }, > "note_date": { > "type": ["string", "null"], >+ "readOnly": true, > "format": "date", > "description": "Datetime of the issue note" > } >diff --git a/api/v1/swagger/paths/checkouts.json b/api/v1/swagger/paths/checkouts.json >index ca6d970dbb..e422f8a9f5 100644 >--- a/api/v1/swagger/paths/checkouts.json >+++ b/api/v1/swagger/paths/checkouts.json >@@ -74,6 +74,45 @@ > "circulate": "circulate_remaining_permissions" > } > } >+ }, >+ "put": { >+ "x-mojo-to": "Checkouts#update", >+ "operationId": "updateCheckout", >+ "tags": ["patrons", "checkouts"], >+ "parameters": [ >+ { >+ "$ref": "../parameters.json#/checkout_id_pp" >+ }, >+ { >+ "name": "body", >+ "in": "body", >+ "description": "A JSON object containing information on the checkout", >+ "required": true, >+ "schema": { >+ "$ref": "../definitions.json#/checkout" >+ } >+ } >+ ], >+ "produces": ["application/json"], >+ "responses": { >+ "200": { >+ "description": "Updated borrower's checkout", >+ "schema": { "$ref": "../definitions.json#/checkout" } >+ }, >+ "403": { >+ "description": "Access forbidden", >+ "schema": { "$ref": "../definitions.json#/error" } >+ }, >+ "404": { >+ "description": "Checkout not found", >+ "schema": { "$ref": "../definitions.json#/error" } >+ } >+ }, >+ "x-koha-authorization": { >+ "permissions": { >+ "circulate": "circulate_remaining_permissions" >+ } >+ } > } > }, > "/checkouts/{checkout_id}/renewal": { >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24609
:
98924
|
98925
|
99021
|
99022
|
115879
|
115880
|
115881
|
126191
|
126192
|
126193
|
126194
|
126316
|
126317
|
126318
|
126319
|
126320
|
126321
|
126917
|
126921
|
126922
|
126923
|
126924
|
126925
|
126926
|
126927
|
126928