Bugzilla – Attachment 115879 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.64 KB, created by
Martin Renvoize
on 2021-01-27 12:19:41 UTC
(
hide
)
Description:
Bug 24609: Create PUT /checkouts/{checkout_id}
Filename:
MIME Type:
Creator:
Martin Renvoize
Created:
2021-01-27 12:19:41 UTC
Size:
5.64 KB
patch
obsolete
>From ae118e0fb73f29d3212c3e86422f272e4a1eff49 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 93feeaeb24..c20147a5e0 100644 >--- a/Koha/REST/V1/Checkouts.pm >+++ b/Koha/REST/V1/Checkouts.pm >@@ -241,4 +241,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 6976d5da5f..dd5fb8a24b 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,6 +22,7 @@ > }, > "library_id": { > "type": ["string", "null"], >+ "readOnly": true, > "description": "code of the library the item was checked out" > }, > "issuer_id": { >@@ -27,16 +31,19 @@ > }, > "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" > }, > "unseen_renewals": { >@@ -45,31 +52,38 @@ > }, > "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 cc2841b28d..af76b23e0d 100644 >--- a/api/v1/swagger/paths/checkouts.json >+++ b/api/v1/swagger/paths/checkouts.json >@@ -80,6 +80,45 @@ > "x-koha-embed": [ > "issuer" > ] >+ }, >+ "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.20.1
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