Bug 34333 - Add cancellation request information embed option to the holds endpoint
Summary: Add cancellation request information embed option to the holds endpoint
Status: Pushed to oldstable
Alias: None
Product: Koha
Classification: Unclassified
Component: REST API (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Tomás Cohen Arazi
QA Contact:
URL:
Keywords:
Depends on:
Blocks: 35658
  Show dependency treegraph
 
Reported: 2023-07-20 18:48 UTC by Tomás Cohen Arazi
Modified: 2023-12-28 13:15 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.11.00,23.05.04,22.11.11


Attachments
Bug 34333: Add Koha::Hold->cancellation_requested (2.47 KB, patch)
2023-07-21 00:00 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 34333: Add embed option for `cancellation_requested` for holds (3.05 KB, patch)
2023-07-21 00:00 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 34333: Add Koha::Hold->cancellation_requested (2.52 KB, patch)
2023-09-16 21:33 UTC, David Nind
Details | Diff | Splinter Review
Bug 34333: Add embed option for `cancellation_requested` for holds (3.09 KB, patch)
2023-09-16 21:34 UTC, David Nind
Details | Diff | Splinter Review
Bug 34333: Add Koha::Hold->cancellation_requested (2.58 KB, patch)
2023-09-18 10:44 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 34333: Add embed option for `cancellation_requested` for holds (3.16 KB, patch)
2023-09-18 10:44 UTC, Martin Renvoize
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Tomás Cohen Arazi 2023-07-20 18:48:17 UTC
When rendering holds tables either in Koha, or in external systems consuming the API, it would be handy to have this information, to give special handling and links to those holds.
Comment 1 Tomás Cohen Arazi 2023-07-21 00:00:40 UTC
Created attachment 153744 [details] [review]
Bug 34333: Add Koha::Hold->cancellation_requested

This patch adds a helper method for telling if a hold has cancellation
requests. To be used for embedding such information.

To test:
1. Apply this patch
2. Run:
   $ ktd --shell
  k$ prove t/db_dependent/Koha/Hold.t
=> SUCCESS: Tests pass, the new method is covered by tests.
3. Sign off :-D
Comment 2 Tomás Cohen Arazi 2023-07-21 00:00:44 UTC
Created attachment 153745 [details] [review]
Bug 34333: Add embed option for `cancellation_requested` for holds

This patch adds the `cancellation_requested` attribute to the hold
object definition, and allows embeding it as on the different holds
endpoints that migt be useful.

To test:
1. Apply this patches
2. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/Hold.t \
           t/db_dependent/api/v1/*holds.t
=> SUCCESS: Tests pass!
3. Play with your REST tool (Postman?) on the following endpoints:
   GET http://localhost:8081/api/v1/holds
   GET http://localhost:8081/api/v1/patrons/:patron_id/holds
on both, pass and not pass the `x-koha-embed` header with
`cancellation_requested` on it.
=> SUCCESS: It is easy! You see the attribute and you don't, and the
content makes sense!
4. Sign off :-D
Comment 3 David Nind 2023-09-16 21:33:58 UTC
Created attachment 155735 [details] [review]
Bug 34333: Add Koha::Hold->cancellation_requested

This patch adds a helper method for telling if a hold has cancellation
requests. To be used for embedding such information.

To test:
1. Apply this patch
2. Run:
   $ ktd --shell
  k$ prove t/db_dependent/Koha/Hold.t
=> SUCCESS: Tests pass, the new method is covered by tests.
3. Sign off :-D

Signed-off-by: David Nind <david@davidnind.com>
Comment 4 David Nind 2023-09-16 21:34:01 UTC
Created attachment 155736 [details] [review]
Bug 34333: Add embed option for `cancellation_requested` for holds

This patch adds the `cancellation_requested` attribute to the hold
object definition, and allows embeding it as on the different holds
endpoints that migt be useful.

To test:
1. Apply this patches
2. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/Hold.t \
           t/db_dependent/api/v1/*holds.t
=> SUCCESS: Tests pass!
3. Play with your REST tool (Postman?) on the following endpoints:
   GET http://localhost:8081/api/v1/holds
   GET http://localhost:8081/api/v1/patrons/:patron_id/holds
on both, pass and not pass the `x-koha-embed` header with
`cancellation_requested` on it.
=> SUCCESS: It is easy! You see the attribute and you don't, and the
content makes sense!
4. Sign off :-D

Signed-off-by: David Nind <david@davidnind.com>
Comment 5 David Nind 2023-09-16 21:36:41 UTC
Testing notes (using KTD and Postman):

1. Enable RESTBasicAuth 

2. Place some holds.

3. When `x-koha-embed` header with `cancellation_requested` added, there is an extra line in results for each hold: "cancellation_requested": false,
Comment 6 Martin Renvoize 2023-09-18 10:44:03 UTC
Created attachment 155794 [details] [review]
Bug 34333: Add Koha::Hold->cancellation_requested

This patch adds a helper method for telling if a hold has cancellation
requests. To be used for embedding such information.

To test:
1. Apply this patch
2. Run:
   $ ktd --shell
  k$ prove t/db_dependent/Koha/Hold.t
=> SUCCESS: Tests pass, the new method is covered by tests.
3. Sign off :-D

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 7 Martin Renvoize 2023-09-18 10:44:05 UTC
Created attachment 155795 [details] [review]
Bug 34333: Add embed option for `cancellation_requested` for holds

This patch adds the `cancellation_requested` attribute to the hold
object definition, and allows embeding it as on the different holds
endpoints that migt be useful.

To test:
1. Apply this patches
2. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/Hold.t \
           t/db_dependent/api/v1/*holds.t
=> SUCCESS: Tests pass!
3. Play with your REST tool (Postman?) on the following endpoints:
   GET http://localhost:8081/api/v1/holds
   GET http://localhost:8081/api/v1/patrons/:patron_id/holds
on both, pass and not pass the `x-koha-embed` header with
`cancellation_requested` on it.
=> SUCCESS: It is easy! You see the attribute and you don't, and the
content makes sense!
4. Sign off :-D

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 8 Martin Renvoize 2023-09-18 10:45:45 UTC
Clear improvement, no QA issues.. Passing.
Comment 9 Tomás Cohen Arazi 2023-09-18 18:54:48 UTC
Pushed to master for 23.11.

Nice work everyone, thanks!
Comment 10 Fridolin Somers 2023-09-18 21:42:40 UTC
Small enhancement on API, I choose to backport

Pushed to 23.05.x for 23.05.04
Comment 11 Matt Blenkinsop 2023-10-12 16:00:49 UTC
Nice work everyone!

Pushed to oldstable for 22.11.x
Comment 12 Jonathan Druart 2023-12-20 08:07:06 UTC
Tomas, yesterday's weirdness is coming from:

+      - name: x-koha-embed
+        in: header
+        required: false
+        description: Embed list sent as a request header
+        type: array
+        items:
+          type: string
+          enum:
+            - cancellation_requested
+          collectionFormat: csv

collectionFormat is an attribute of the header, no the items, it should have been:

+      - name: x-koha-embed
+        in: header
+        required: false
+        description: Embed list sent as a request header
+        type: array
+        items:
+          type: string
+          enum:
+            - cancellation_requested
+        collectionFormat: csv