According to our docs, you can include an array of patron attributes on a patrons PUT request: https://api.koha-community.org/Development.html#tag/patrons/operation/updatePatron When testing I sent: {"category_id":"PT","library_id":"CPL","surname":"Ballard","extended_attributes":[{"extended_attribute_id":"1","type":"SHOW_BCODE","value":"0"}]} And I got an error: [2024/04/03 17:27:40] [ERROR] PUT /api/v1/patrons/21: unhandled exception (Koha::Exceptions::Object::PropertyNotFound)<<No property extended_attributes for Koha::Patron>>
Created attachment 164499 [details] [review] Bug 36505: Unit tests
Created attachment 164500 [details] [review] Bug 36505: Add support for `extended_attributes` in PUT /patrons/:patron_id This patch does what the title says. With it, you will be able to PUT on the already existing endpoint, but also pass: ```json [ { "type": "THE_TYPE", "value": "a" }, ... ] ``` Bonus: to ease testing I added `x-koha-embed: extended_attributes` support. To test: 1. Apply the unit tests 2. Run: $ ktd --shell k$ prove t/db_dependent/api/v1/patrons.t => FAIL: This is not implemented! 3. Apply this patch 4. Repeat 2 => SUCCESS: Exhaustive testes pass! 5. Sign off :-D
Created attachment 164527 [details] [review] Bug 36505: (follow-up) Consistent error codes in POST
When I try to apply this patch I get this error: Applying: Bug 36505: Add support for `extended_attributes` in PUT /patrons/:patron_id error: sha1 information is lacking or useless (Koha/REST/V1/Patrons.pm). error: could not build fake ancestor Patch failed at 0001 Bug 36505: Add support for `extended_attributes` in PUT /patrons/:patron_id Thanks for working on this! We need this to work for our eCard renewal vendor to update patron attibutes correctly.
This was missing a dependency. Hopefully those will be pushed pretty soon.
(In reply to Tomás Cohen Arazi from comment #5) > This was missing a dependency. Hopefully those will be pushed pretty soon. Thanks Tomás. Is there a bug to watch for the dependency to be pushed. I would like to follow up and test this when I can.
(In reply to Brendan Lawlor from comment #6) > (In reply to Tomás Cohen Arazi from comment #5) > > This was missing a dependency. Hopefully those will be pushed pretty soon. > > Thanks Tomás. Is there a bug to watch for the dependency to be pushed. I > would like to follow up and test this when I can. Hi, Brendan. If you are testing using KTD, when you try to do a: ```shell git fetch git checkout origin/master -b bug_36505 git bz apply 36505 ``` the last command should offer you the option to recursivelly apply the dependencies! If you feel like, give it a try. My only advise is: sometimes it is not smart enough and it offers you to apply an already applied bug. But that doesn't happen quite often. Thanks for your interest on this bug!
Created attachment 164771 [details] [review] Bug 36505: Unit tests Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>
Created attachment 164772 [details] [review] Bug 36505: Add support for `extended_attributes` in PUT /patrons/:patron_id This patch does what the title says. With it, you will be able to PUT on the already existing endpoint, but also pass: ```json [ { "type": "THE_TYPE", "value": "a" }, ... ] ``` Bonus: to ease testing I added `x-koha-embed: extended_attributes` support. To test: 1. Apply the unit tests 2. Run: $ ktd --shell k$ prove t/db_dependent/api/v1/patrons.t => FAIL: This is not implemented! 3. Apply this patch 4. Repeat 2 => SUCCESS: Exhaustive testes pass! 5. Sign off :-D Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>
Created attachment 164773 [details] [review] Bug 36505: (follow-up) Consistent error codes in POST Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>
Thanks Tomás! Testing notes: Apply dependencies and patch ```shell git fetch git checkout origin/master -b bug_36505 git bz apply 36505 ``` Enable system preference RESTOAuth2ClientCredentials Create a patron with edit borrowers permissions Get an API authentication token curl --location --request PUT 'http://localhost:8080/api/v1/patrons/21' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer MTcxMjg0OTAyOC00NTc2OTEtMC4yNTUwNzU4MzY0NjM2NS1SbVF0UzdROW1qTDE0b1ViVjJKYXhuSFFlblZLcjY=' \ --data '{ "category_id": "PT", "library_id": "CPL", "surname": "Ballard", "extended_attributes": [ { "extended_attribute_id": "1", "type": "SHOW_BCODE", "value": "1" } ] }' This returns 200 and updates the patron attribute! Run test: kohadev-koha@kohadevbox:koha(bug_36505)$ prove t/db_dependent/api/v1/patrons.t t/db_dependent/api/v1/patrons.t .. ok All tests successful. Files=1, Tests=7, 11 wallclock secs ( 0.03 usr 0.01 sys + 9.11 cusr 0.65 csys = 9.80 CPU) Result: PASS
Created attachment 165409 [details] [review] Bug 36505: Unit tests Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Created attachment 165410 [details] [review] Bug 36505: Add support for `extended_attributes` in PUT /patrons/:patron_id This patch does what the title says. With it, you will be able to PUT on the already existing endpoint, but also pass: ```json [ { "type": "THE_TYPE", "value": "a" }, ... ] ``` Bonus: to ease testing I added `x-koha-embed: extended_attributes` support. To test: 1. Apply the unit tests 2. Run: $ ktd --shell k$ prove t/db_dependent/api/v1/patrons.t => FAIL: This is not implemented! 3. Apply this patch 4. Repeat 2 => SUCCESS: Exhaustive testes pass! 5. Sign off :-D Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Created attachment 165411 [details] [review] Bug 36505: (follow-up) Consistent error codes in POST Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Fixed and working, thanks Tomas. Tests passing and present. Passing QA
This is just the tip of the iceberg, the dependency includes several "enh" bugs. Skipping for now (will be back later).
Pushed for 24.05! Well done everyone, thank you!
This is a big patch I prefer not to backport to 23.11.x
API change, nothing to add/edit in the Koha manual. I assume API documentation is done automatically?