Browse Source

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>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
21.05.x
Tomás Cohen Arazi 2 years ago
committed by Jonathan Druart
parent
commit
fa7a80a475
  1. 12
      Koha/REST/V1/Patrons.pm

12
Koha/REST/V1/Patrons.pm

@ -73,13 +73,19 @@ sub get {
return try {
my $patron_id = $c->validation->param('patron_id');
my $patron = Koha::Patrons->find($patron_id);
my $patron = $c->objects->find( Koha::Patrons->new, $patron_id );
unless ($patron) {
return $c->render( status => 404, openapi => { error => "Patron not found." } );
return $c->render(
status => 404,
openapi => { error => "Patron not found." }
);
}
return $c->render( status => 200, openapi => $patron->to_api );
return $c->render(
status => 200,
openapi => $patron
);
}
catch {
$c->unhandled_exception($_);

Loading…
Cancel
Save