Bug 23667

Summary: Add API route for listing items
Product: Koha Reporter: Stefan Kugler <kugler_stefan>
Component: REST APIAssignee: Tomás Cohen Arazi <tomascohen>
Status: CLOSED FIXED QA Contact: Martin Renvoize <martin.renvoize>
Severity: enhancement    
Priority: P5 - low CC: joonas.kylmala, katrin.fischer, martin.renvoize, tomascohen
Version: Main   
Hardware: All   
OS: All   
URL: https://wiki.koha-community.org/wiki/Items_endpoint_RFC
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
19.11.00
Bug Depends on:    
Bug Blocks: 33146    
Attachments: Bug 23667: Add spec
Bug 23667: Add route to GET /items
Bug 23667: (follow-up) Cleanup
Bug 23667: Add route to GET /items
Bug 23667: Add spec
Bug 23667: Add route to GET /items
Bug 23667: Add spec
Bug 23667: Add route to GET /items

Description Stefan Kugler 2019-09-22 22:31:06 UTC
Add API route to get an item by barcode (extension to bug 16825), eg:

GET /items?barcode={barcode}
Comment 1 Tomás Cohen Arazi 2019-09-23 14:17:54 UTC
We really need to implement the

GET /items

route. Which would include filters on many of the item attributes. including barcode. It will, tough, return a list of matching items (probably only one if filtering by barcode).
Comment 2 Tomás Cohen Arazi 2019-09-23 15:52:07 UTC
Created attachment 93129 [details] [review]
Bug 23667: Add spec
Comment 3 Tomás Cohen Arazi 2019-09-23 15:52:11 UTC Comment hidden (obsolete)
Comment 4 Tomás Cohen Arazi 2019-09-23 15:54:52 UTC Comment hidden (obsolete)
Comment 5 Joonas Kylmälä 2019-09-30 10:17:52 UTC Comment hidden (obsolete)
Comment 6 Tomás Cohen Arazi 2019-09-30 10:24:01 UTC
Created attachment 93230 [details] [review]
Bug 23667: Add route to GET /items

This patchset introduces a route to fetch items. It relies on the
already implemented code/mappings to get a single item.

To test:
- Apply this patches
- Run:
  $ kshell
 k$ prove t/db_dependent/api/v1/items.t
=> SUCCESS: Tests pass!
- Try the endpoint with your favourite API tool (Postman?)
- Sign off :-D

Note: to do exact searching on barcode, you need to build the query like
this:

GET /api/v1/items?external_id=<your_barcode>&_match=exact
Comment 7 Tomás Cohen Arazi 2019-09-30 10:25:34 UTC
(In reply to Joonas Kylmälä from comment #5)
> (In reply to Tomás Cohen Arazi from comment #4)
> > Created attachment 93131 [details] [review] [review] [review]
> > Bug 23667: (follow-up) Cleanup
> 
> Since you are the author in both of these patches can you submit a new
> version of "Bug 23667: Add route to GET /items" instead of creating a
> follow-up? It would make it easier to review and read git history. See
> "follow-up patches must be squashed if not signed-off yet, and the history
> is not needed" in
> https://wiki.koha-community.org/wiki/
> Development_IRC_meeting_27_September_2017

Thanks, good catch. I didn't know/remember that rule.
Comment 8 Jesse Maseto 2019-10-02 09:59:40 UTC
Created attachment 93404 [details] [review]
Bug 23667: Add spec

Signed-off-by: Jesse Maseto <jesse@bywatersolutions.com>
Comment 9 Jesse Maseto 2019-10-02 10:00:07 UTC
Created attachment 93405 [details] [review]
Bug 23667: Add route to GET /items

This patchset introduces a route to fetch items. It relies on the
already implemented code/mappings to get a single item.

To test:
- Apply this patches
- Run:
  $ kshell
 k$ prove t/db_dependent/api/v1/items.t
=> SUCCESS: Tests pass!
- Try the endpoint with your favourite API tool (Postman?)
- Sign off :-D

Note: to do exact searching on barcode, you need to build the query like
this:

GET /api/v1/items?external_id=<your_barcode>&_match=exact

Signed-off-by: Jesse Maseto <jesse@bywatersolutions.com>
Comment 10 Martin Renvoize 2019-10-29 12:11:00 UTC
Created attachment 94829 [details] [review]
Bug 23667: Add spec

Signed-off-by: Jesse Maseto <jesse@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 11 Martin Renvoize 2019-10-29 12:11:03 UTC
Created attachment 94830 [details] [review]
Bug 23667: Add route to GET /items

This patchset introduces a route to fetch items. It relies on the
already implemented code/mappings to get a single item.

To test:
- Apply this patches
- Run:
  $ kshell
 k$ prove t/db_dependent/api/v1/items.t
=> SUCCESS: Tests pass!
- Try the endpoint with your favourite API tool (Postman?)
- Sign off :-D

Note: to do exact searching on barcode, you need to build the query like
this:

GET /api/v1/items?external_id=<your_barcode>&_match=exact

Signed-off-by: Jesse Maseto <jesse@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 12 Martin Renvoize 2019-10-29 12:11:25 UTC
Works well, passes qa scripts.. Passing QA
Comment 13 Martin Renvoize 2019-10-29 12:21:02 UTC
Nice work!

Pushed to master for 19.11.00