Created attachment 117660 [details] [review] Bug 27855: Add extended_attribute OpenAPI spec
Created attachment 117661 [details] [review] Bug 27855: Implement Koha::Patron::Attribute->to_api_mapping This patch introduces a mapping to render extended attributes on the API. As they have an ID, and they will generally be used on the /patrons umbrella, I removed the borrowernumber on the mapping. Another option would be to add the field, but make it optional. It really feels redundant, so I take it out for now.
Created attachment 117662 [details] [review] Bug 27855: Make GET /patrons/:patron_id use objects.find This patch makes the route for fetching a patron use the objects.find helper instead of a plain Koha::Patrons->find. This gives the controller embedding superpowers. To test, we just need to check nothing broke: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/api/v1/patrons.t => SUCCESS: Tests pass! 3. Sign off :-D
Created attachment 117663 [details] [review] Bug 27855: Add 'extended_attributes' embedding to the spec This patch just adds: - The optional 'extended_attribute' attribute to the patron object OpenAPI definition. It consists of an array of extended_attribute objects. - Add the x-koha-embed: [ 'extended_attributes' ] definition on the GET routes for patrons, allowing immedite availability of the 'extended_attributes' embedding feature. To test: 1. Apply this patchset 2. Restart Plack 3. Have some known patron_id/borrowernumber that has some extended attributes ('Patron attributes' on the UI). 4. Enable Basic authentication 5. Assuming the known patron_id is 1, point your favourite REST tool to http://kohadev-intra.myDNSname.org:8081/api/v1/patrons/1 e.g.: if your user/pass is koha/koha curl --location --request GET 'http://kohadev-intra.myDNSname.org:8081/api/v1/patrons/1' \ --header 'Content-Type: application/json' \ --header 'Authorization: Basic a29oYTprb2hh' => SUCCESS: You get the patron object correctly, no extended_attributes 6. Repeat 5, adding the x-koha-embed header like this: curl --location --request GET 'http://kohadev-intra.myDNSname.org:8081/api/v1/patrons/1' \ --header 'Content-Type: application/json' \ --header 'x-koha-embed: extended_attributes' \ --header 'Authorization: Basic a29oYTprb2hh' => SUCCESS: You get the patron, with the extended attributes inside! 7. Sign off :-D
Created attachment 117681 [details] [review] Bug 27855: Add extended_attribute OpenAPI spec Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Created attachment 117682 [details] [review] Bug 27855: Implement Koha::Patron::Attribute->to_api_mapping This patch introduces a mapping to render extended attributes on the API. As they have an ID, and they will generally be used on the /patrons umbrella, I removed the borrowernumber on the mapping. Another option would be to add the field, but make it optional. It really feels redundant, so I take it out for now. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Created attachment 117683 [details] [review] Bug 27855: Make GET /patrons/:patron_id use objects.find This patch makes the route for fetching a patron use the objects.find helper instead of a plain Koha::Patrons->find. This gives the controller embedding superpowers. To test, we just need to check nothing broke: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/api/v1/patrons.t => SUCCESS: Tests pass! 3. Sign off :-D Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Created attachment 117684 [details] [review] Bug 27855: Add 'extended_attributes' embedding to the spec This patch just adds: - The optional 'extended_attribute' attribute to the patron object OpenAPI definition. It consists of an array of extended_attribute objects. - Add the x-koha-embed: [ 'extended_attributes' ] definition on the GET routes for patrons, allowing immedite availability of the 'extended_attributes' embedding feature. To test: 1. Apply this patchset 2. Restart Plack 3. Have some known patron_id/borrowernumber that has some extended attributes ('Patron attributes' on the UI). 4. Enable Basic authentication 5. Assuming the known patron_id is 1, point your favourite REST tool to http://kohadev-intra.myDNSname.org:8081/api/v1/patrons/1 e.g.: if your user/pass is koha/koha curl --location --request GET 'http://kohadev-intra.myDNSname.org:8081/api/v1/patrons/1' \ --header 'Content-Type: application/json' \ --header 'Authorization: Basic a29oYTprb2hh' => SUCCESS: You get the patron object correctly, no extended_attributes 6. Repeat 5, adding the x-koha-embed header like this: curl --location --request GET 'http://kohadev-intra.myDNSname.org:8081/api/v1/patrons/1' \ --header 'Content-Type: application/json' \ --header 'x-koha-embed: extended_attributes' \ --header 'Authorization: Basic a29oYTprb2hh' => SUCCESS: You get the patron, with the extended attributes inside! 7. Sign off :-D Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Created attachment 117685 [details] [review] Bug 27855: Add extended_attribute OpenAPI spec Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Created attachment 117686 [details] [review] Bug 27855: Implement Koha::Patron::Attribute->to_api_mapping This patch introduces a mapping to render extended attributes on the API. As they have an ID, and they will generally be used on the /patrons umbrella, I removed the borrowernumber on the mapping. Another option would be to add the field, but make it optional. It really feels redundant, so I take it out for now. Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Created attachment 117687 [details] [review] Bug 27855: Make GET /patrons/:patron_id use objects.find This patch makes the route for fetching a patron use the objects.find helper instead of a plain Koha::Patrons->find. This gives the controller embedding superpowers. To test, we just need to check nothing broke: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/api/v1/patrons.t => SUCCESS: Tests pass! 3. Sign off :-D Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Created attachment 117688 [details] [review] Bug 27855: Add 'extended_attributes' embedding to the spec This patch just adds: - The optional 'extended_attribute' attribute to the patron object OpenAPI definition. It consists of an array of extended_attribute objects. - Add the x-koha-embed: [ 'extended_attributes' ] definition on the GET routes for patrons, allowing immedite availability of the 'extended_attributes' embedding feature. To test: 1. Apply this patchset 2. Restart Plack 3. Have some known patron_id/borrowernumber that has some extended attributes ('Patron attributes' on the UI). 4. Enable Basic authentication 5. Assuming the known patron_id is 1, point your favourite REST tool to http://kohadev-intra.myDNSname.org:8081/api/v1/patrons/1 e.g.: if your user/pass is koha/koha curl --location --request GET 'http://kohadev-intra.myDNSname.org:8081/api/v1/patrons/1' \ --header 'Content-Type: application/json' \ --header 'Authorization: Basic a29oYTprb2hh' => SUCCESS: You get the patron object correctly, no extended_attributes 6. Repeat 5, adding the x-koha-embed header like this: curl --location --request GET 'http://kohadev-intra.myDNSname.org:8081/api/v1/patrons/1' \ --header 'Content-Type: application/json' \ --header 'x-koha-embed: extended_attributes' \ --header 'Authorization: Basic a29oYTprb2hh' => SUCCESS: You get the patron, with the extended attributes inside! 7. Sign off :-D Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Created attachment 117689 [details] [review] Bug 27855: (QA follow-up) Merge extended_attribute.json into patron.json As the extended_attribute object is only ever returned inline with patrons,this patch merges the specification into the patron definition to clarify it usage. Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Created attachment 117690 [details] [review] Bug 27855: Add extended_attribute OpenAPI spec Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Created attachment 117691 [details] [review] Bug 27855: Implement Koha::Patron::Attribute->to_api_mapping This patch introduces a mapping to render extended attributes on the API. As they have an ID, and they will generally be used on the /patrons umbrella, I removed the borrowernumber on the mapping. Another option would be to add the field, but make it optional. It really feels redundant, so I take it out for now. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Created attachment 117692 [details] [review] Bug 27855: Make GET /patrons/:patron_id use objects.find This patch makes the route for fetching a patron use the objects.find helper instead of a plain Koha::Patrons->find. This gives the controller embedding superpowers. To test, we just need to check nothing broke: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/api/v1/patrons.t => SUCCESS: Tests pass! 3. Sign off :-D Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Created attachment 117693 [details] [review] Bug 27855: Add 'extended_attributes' embedding to the spec This patch just adds: - The optional 'extended_attribute' attribute to the patron object OpenAPI definition. It consists of an array of extended_attribute objects. - Add the x-koha-embed: [ 'extended_attributes' ] definition on the GET routes for patrons, allowing immedite availability of the 'extended_attributes' embedding feature. To test: 1. Apply this patchset 2. Restart Plack 3. Have some known patron_id/borrowernumber that has some extended attributes ('Patron attributes' on the UI). 4. Enable Basic authentication 5. Assuming the known patron_id is 1, point your favourite REST tool to http://kohadev-intra.myDNSname.org:8081/api/v1/patrons/1 e.g.: if your user/pass is koha/koha curl --location --request GET 'http://kohadev-intra.myDNSname.org:8081/api/v1/patrons/1' \ --header 'Content-Type: application/json' \ --header 'Authorization: Basic a29oYTprb2hh' => SUCCESS: You get the patron object correctly, no extended_attributes 6. Repeat 5, adding the x-koha-embed header like this: curl --location --request GET 'http://kohadev-intra.myDNSname.org:8081/api/v1/patrons/1' \ --header 'Content-Type: application/json' \ --header 'x-koha-embed: extended_attributes' \ --header 'Authorization: Basic a29oYTprb2hh' => SUCCESS: You get the patron, with the extended attributes inside! 7. Sign off :-D Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Created attachment 117694 [details] [review] Bug 27855: (QA follow-up) Merge extended_attribute.json into patron.json As the extended_attribute object is only ever returned inline with patrons,this patch merges the specification into the patron definition to clarify it usage. Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Created attachment 117695 [details] [review] Bug 27855: (QA follow-up) Rename extended_attribute to patron_extended_attribute This path renames the extended_attribute definition to patron_extended_attribute to clarify that these attributes are always attached to a patron and not a more generic class of attributes. Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Works great.. this is almost too easy with the nice foundations we have in the API helpers now! Passing QA
Is there a plan for those routes to be used from Koha? moremember and memberentry would benefit a lot from this.
Pushed to master for 21.05, thanks to everybody involved!
(In reply to Jonathan Druart from comment #21) > Is there a plan for those routes to be used from Koha? > moremember and memberentry would benefit a lot from this. No plan yet.. we were very keen to have it for customers who want to start managing background patron imports using a modern API. However.. I do love the idea of moving moremember and memberentry forward using these routes :)
Enhancement not pushed to 20.11.x