By now a new checkout is built at least by params patron_id and item_id. This makes it a bit difficult if you only have a barcode of the item available, f.e. from RFID middleware applications, as you have to make another API call to retrieve the item_id for a barcode first. I would propose to enhance the POST /checkouts (addCheckout) route to accept either item_id or barcode (external_id in API) as JSON params.
Created attachment 168503 [details] [review] Bug 37253: Enhance POST /checkouts endpoint to accept barcode or item_id This patch adds external_id as a body param in POST /checkouts which acts as the items barcode. This enhances the checkouts route to checkout items directly via barcode which could be useful for external tools like Koha Offline Circulation Tool Test plan: a) apply patch b) enable system preference RESTBasicAuth c) check out an item via an API testing tool. Be sure that item is not checked out already. Auth: username: koha & password: koha Body JSON: { "external_id" : "39999000011418", "library_id": "CPL" } POST http://localhost:8081/api/v1/checkouts d) check response code 201 and response content
Created attachment 168507 [details] [review] Bug 37253: Enhance POST /checkouts endpoint to accept barcode or item_id This patch adds external_id as a body param in POST /checkouts which acts as the items barcode. This enhances the checkouts route to checkout items directly via barcode which could be useful for external tools like Koha Offline Circulation Tool Test plan: a) apply patch b) enable system preference RESTBasicAuth c) check out an item via an API testing tool. Be sure that item is not checked out already. Auth: username: koha & password: koha Body JSON: { "external_id" : "39999000011418", "library_id": "CPL", "patron_id": 5 } POST http://localhost:8081/api/v1/checkouts d) check response code 201 and response content Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Created attachment 168508 [details] [review] Bug 37253: Tidy changes Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
All works fine, just amended the test plan to include a patron_id and tidied a few lines to satisfy the QA tests
(In reply to Matt Blenkinsop from comment #4) > All works fine, just amended the test plan to include a patron_id how could I miss that :/ > and tidied a few lines to satisfy the QA tests thx
* Proving /kohadevbox/koha/t/db_dependent/api/v1/checkouts.t KO! # Failed test '201 Created' # at /kohadevbox/koha/t/db_dependent/api/v1/checkouts.t line 495. # got: '400' # expected: '201' # Looks like you failed 1 test of 12. # Failed test 'add checkout' # at /kohadevbox/koha/t/db_dependent/api/v1/checkouts.t line 555. # Looks like you failed 1 test of 108. /kohadevbox/koha/t/db_dependent/api/v1/checkouts.t .. Dubious, test returned 1 (wstat 256, 0x100) Failed 1/108 subtests Test Summary Report ------------------- /kohadevbox/koha/t/db_dependent/api/v1/checkouts.t (Wstat: 256 (exited 1) Tests: 108 Failed: 1) Failed test: 108 Non-zero exit status: 1 Files=1, Tests=108, 4 wallclock secs ( 0.01 usr 0.00 sys + 3.38 cusr 0.21 csys = 3.60 CPU) Result: FAIL
(In reply to Kyle M Hall (khall) from comment #6) > * Proving /kohadevbox/koha/t/db_dependent/api/v1/checkouts.t KO! > > # Failed test '201 Created' > # at /kohadevbox/koha/t/db_dependent/api/v1/checkouts.t line 495. > # got: '400' > # expected: '201' > # Looks like you failed 1 test of 12. > > # Failed test 'add checkout' > # at /kohadevbox/koha/t/db_dependent/api/v1/checkouts.t line 555. > # Looks like you failed 1 test of 108. > /kohadevbox/koha/t/db_dependent/api/v1/checkouts.t .. > Dubious, test returned 1 (wstat 256, 0x100) > Failed 1/108 subtests > > Test Summary Report > ------------------- > /kohadevbox/koha/t/db_dependent/api/v1/checkouts.t (Wstat: 256 (exited 1) > Tests: 108 Failed: 1) > Failed test: 108 > Non-zero exit status: 1 > Files=1, Tests=108, 4 wallclock secs ( 0.01 usr 0.00 sys + 3.38 cusr > 0.21 csys = 3.60 CPU) > Result: FAIL hey Kyle, did you run yarn build after applying the patch?
Hi, I'd like to point out we should accept one of them but not both. If we accepted both, then we should check they belong to the same item! The two consecutive if+find look weird in the sense of the paragraph above. I had to deal with a similar situation in Koha/REST/V1/Auth/Password.pm:55
Created attachment 173014 [details] [review] Bug 37253: Tidy changes Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Created attachment 173015 [details] [review] Bug 37253: Enhance POST /checkouts endpoint to accept barcode or item_id This patch adds external_id as a body param in POST /checkouts which acts as the items barcode. This enhances the checkouts route to checkout items directly via barcode which could be useful for external tools like Koha Offline Circulation Tool Test plan: a) apply patch b) enable system preference RESTBasicAuth c) check out an item via an API testing tool. Be sure that item is not checked out already. Auth: username: koha & password: koha Body JSON: { "external_id" : "39999000011418", "library_id": "CPL", "patron_id": 5 } POST http://localhost:8081/api/v1/checkouts d) check response code 201 and response content Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Created attachment 173016 [details] [review] Bug 37253: Tidy changes Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
please ignore last 2 patches a I am struggling with git
Created attachment 173047 [details] [review] Bug 37253: Enhance POST /checkouts endpoint to accept barcode or item_id This patch adds external_id as a body param in POST /checkouts which acts as the items barcode. This enhances the checkouts route to checkout items directly via barcode which could be useful for external tools like Koha Offline Circulation Tool. When item_id and external_id are given a check is performed that both identifiers belong to the same item. Test plan: a) apply patch b) enable system preference RESTBasicAuth c) check out an item via an API testing tool. Be sure that item is not checked out already. Auth: username: koha & password: koha Body JSON: { "external_id" : "39999000011418", "library_id": "CPL", "patron_id": 5 } POST http://localhost:8081/api/v1/checkouts d) check response code 201 and response content Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Jan, please rebase against latest main: ```shell git rebase -i origin/main ``` and resubmit. If it depends on some other bug please mark it so.
(In reply to Tomás Cohen Arazi (tcohen) from comment #14) > Jan, please rebase against latest main: > > ```shell > git rebase -i origin/main > ``` > > and resubmit. If it depends on some other bug please mark it so. I obsoleted the former patches by accident and 'de'obsoleted them. Patch applies now to main
Created attachment 173139 [details] [review] Bug 37253: Enhance POST /checkouts endpoint to accept barcode or item_id This patch adds external_id as a body param in POST /checkouts which acts as the items barcode. This enhances the checkouts route to checkout items directly via barcode which could be useful for external tools like Koha Offline Circulation Tool Test plan: a) apply patch b) enable system preference RESTBasicAuth c) check out an item via an API testing tool. Be sure that item is not checked out already. Auth: username: koha & password: koha Body JSON: { "external_id" : "39999000011418", "library_id": "CPL", "patron_id": 5 } POST http://localhost:8081/api/v1/checkouts d) check response code 201 and response content Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Created attachment 173140 [details] [review] Bug 37253: Enhance POST /checkouts endpoint to accept barcode or item_id This patch adds external_id as a body param in POST /checkouts which acts as the items barcode. This enhances the checkouts route to checkout items directly via barcode which could be useful for external tools like Koha Offline Circulation Tool Test plan: a) apply patch b) enable system preference RESTBasicAuth c) check out an item via an API testing tool. Be sure that item is not checked out already. Auth: username: koha & password: koha Body JSON: { "external_id" : "39999000011418", "library_id": "CPL", "patron_id": 5 } POST http://localhost:8081/api/v1/checkouts d) check response code 201 and response content Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Pushed for 24.11! Well done everyone, thank you!