Browse Source

Bug 26988: (QA follow-up) Make the API return proper library objects

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

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
20.11.x
Tomás Cohen Arazi 4 years ago
committed by Jonathan Druart
parent
commit
1450604029
  1. 16
      Koha/REST/V1/Holds.pm
  2. 8
      api/v1/swagger/paths/holds.json

16
Koha/REST/V1/Holds.pm

@ -406,7 +406,7 @@ sub pickup_locations {
my $c = shift->openapi->valid_input or return;
my $hold_id = $c->validation->param('hold_id');
my $hold = Koha::Holds->find($hold_id);
my $hold = Koha::Holds->find( $hold_id, { prefetch => [ 'patron' ] } );
unless ($hold) {
return $c->render(
@ -416,11 +416,17 @@ sub pickup_locations {
}
return try {
my $pickup_locations = $hold->itemnumber ?
$hold->item->pickup_locations({ patron => $hold->patron }) : $hold->biblio->pickup_locations({ patron => $hold->patron });
warn Data::Dumper::Dumper( $pickup_locations );
my @pickup_locations =
$hold->itemnumber
? @{ $hold->item->pickup_locations( { patron => $hold->patron } ) }
: @{ $hold->biblio->pickup_locations( { patron => $hold->patron } ) };
@pickup_locations = map { $_->to_api } @pickup_locations;
return $c->render( status => 200, openapi => $pickup_locations );
return $c->render(
status => 200,
openapi => \@pickup_locations
);
}
catch {
$c->unhandled_exception($_);

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

@ -625,7 +625,13 @@
"produces": ["application/json"],
"responses": {
"200": {
"description": "Hold pickup location"
"description": "Hold pickup location",
"schema": {
"type": "array",
"items": {
"$ref": "../definitions.json#/library"
}
}
},
"400": {
"description": "Missing or wrong parameters",

Loading…
Cancel
Save