Bug 23666: Add extended attributes routes
authorTomas Cohen Arazi <tomascohen@theke.io>
Thu, 18 Mar 2021 18:15:13 +0000 (15:15 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 22 Apr 2021 12:50:11 +0000 (14:50 +0200)
commitcd2e57a13f0ce4e27b55eb23481b104e78a53af8
treecf18e53eb06abca1f4350448cbfce088ae865c50
parent13bebbaa26161badb4ad490d7477a17cb9d8b420
Bug 23666: Add extended attributes routes

This patch adds routes to handle patron's extended attributes:

GET    /patrons/:patron_id/extended_attributes
POST   /patrons/:patron_id/extended_attributes
PUT    /patrons/:patron_id/extended_attributes <- to overwrite them all
DELETE /patrons/:patron_id/extended_attributes/:extended_attribute_id

Controllers rely on the Koha::Patron methods for retrieving/adding
extended attributes. Exceptions are correctly catch and handled in the
responses. This is all covered by tests as well.

Note: I decidedto override the default sorting on the PUT response,
    because the overloaded search sorting it felt a bit wrong on the API.

To test:
1. Apply this patches
2. Run:
   $ kshell
  k$ prove t/db_dependent/api/v1/patrons_extended_attributes.t
=> SUCCESS: Tests pass!
3. Play with your favourite tool and this routes
=> SUCCESS: They work well!
4. Sign off :-D

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Koha/REST/V1/Patrons/Attributes.pm [new file with mode: 0644]