Bug 29290: Add GET /biblios/:biblio_id/checkouts
This patch adds the required controller method. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
d46492ac23
commit
8fdd52b17c
1 changed files with 36 additions and 0 deletions
|
@ -269,6 +269,42 @@ sub get_items {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
=head3 get_checkouts
|
||||||
|
|
||||||
|
List Koha::Checkout objects
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub get_checkouts {
|
||||||
|
my $c = shift->openapi->valid_input or return;
|
||||||
|
|
||||||
|
my $checked_in = delete $c->validation->output->{checked_in};
|
||||||
|
|
||||||
|
try {
|
||||||
|
my $biblio = Koha::Biblios->find( $c->validation->param('biblio_id') );
|
||||||
|
|
||||||
|
unless ($biblio) {
|
||||||
|
return $c->render(
|
||||||
|
status => 404,
|
||||||
|
openapi => { error => 'Object not found' }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
my $checkouts =
|
||||||
|
($checked_in)
|
||||||
|
? $c->objects->search( scalar $biblio->old_checkouts )
|
||||||
|
: $c->objects->search( scalar $biblio->current_checkouts );
|
||||||
|
|
||||||
|
return $c->render(
|
||||||
|
status => 200,
|
||||||
|
openapi => $checkouts
|
||||||
|
);
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
$c->unhandled_exception($_);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
=head3 pickup_locations
|
=head3 pickup_locations
|
||||||
|
|
||||||
Method that returns the possible pickup_locations for a given biblio
|
Method that returns the possible pickup_locations for a given biblio
|
||||||
|
|
Loading…
Reference in a new issue