Browse Source

Bug 27015: Make pickup locations searchable

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
21.05.x
Tomas Cohen Arazi 2 years ago
committed by Jonathan Druart
parent
commit
a60c1b77f8
  1. 18
      Koha/REST/V1/Holds.pm
  2. 27
      api/v1/swagger/paths/holds.json

18
Koha/REST/V1/Holds.pm

@ -445,6 +445,8 @@ sub pickup_locations {
my $c = shift->openapi->valid_input or return;
my $hold_id = $c->validation->param('hold_id');
# FIXME: We should really skip the path params in $c->objects->search
delete $c->validation->output->{hold_id};
my $hold = Koha::Holds->find( $hold_id, { prefetch => [ 'patron' ] } );
unless ($hold) {
@ -455,16 +457,20 @@ sub pickup_locations {
}
return try {
my @pickup_locations =
$hold->itemnumber
? @{ $hold->item->pickup_locations( { patron => $hold->patron } )->as_list() }
: @{ $hold->biblio->pickup_locations( { patron => $hold->patron } )->as_list() };
my $ps_set;
@pickup_locations = map { $_->to_api } @pickup_locations;
if ( $hold->itemnumber ) {
$ps_set = $hold->item->pickup_locations( { patron => $hold->patron } );
}
else {
$ps_set = $hold->biblio->pickup_locations( { patron => $hold->patron } );
}
my $pickup_locations = $c->objects->search( $ps_set );
return $c->render(
status => 200,
openapi => \@pickup_locations
openapi => $pickup_locations
);
}
catch {

27
api/v1/swagger/paths/holds.json

@ -619,9 +619,32 @@
"x-mojo-to": "Holds#pickup_locations",
"operationId": "getHoldPickupLocations",
"tags": ["holds"],
"parameters": [{
"parameters": [
{
"$ref": "../parameters.json#/hold_id_pp"
}],
},
{
"$ref": "../parameters.json#/match"
},
{
"$ref": "../parameters.json#/order_by"
},
{
"$ref": "../parameters.json#/page"
},
{
"$ref": "../parameters.json#/per_page"
},
{
"$ref": "../parameters.json#/q_param"
},
{
"$ref": "../parameters.json#/q_body"
},
{
"$ref": "../parameters.json#/q_header"
}
],
"produces": ["application/json"],
"responses": {
"200": {

Loading…
Cancel
Save