Lines 518-523
sub update_pickup_location {
Link Here
|
518 |
my $c = shift->openapi->valid_input or return; |
518 |
my $c = shift->openapi->valid_input or return; |
519 |
|
519 |
|
520 |
my $hold_id = $c->validation->param('hold_id'); |
520 |
my $hold_id = $c->validation->param('hold_id'); |
|
|
521 |
my $body = $c->validation->param('body'); |
522 |
my $pickup_library_id = $body->{pickup_library_id}; |
523 |
|
521 |
my $hold = Koha::Holds->find($hold_id); |
524 |
my $hold = Koha::Holds->find($hold_id); |
522 |
|
525 |
|
523 |
unless ($hold) { |
526 |
unless ($hold) { |
Lines 528-540
sub update_pickup_location {
Link Here
|
528 |
} |
531 |
} |
529 |
|
532 |
|
530 |
return try { |
533 |
return try { |
531 |
my $pickup_location = $c->req->json; |
|
|
532 |
|
534 |
|
533 |
$hold->branchcode($pickup_location)->store; |
535 |
$hold->set_pickup_location({ library_id => $pickup_library_id }); |
534 |
|
536 |
|
535 |
return $c->render( status => 200, openapi => $pickup_location ); |
537 |
return $c->render( |
|
|
538 |
status => 200, |
539 |
openapi => { |
540 |
pickup_library_id => $pickup_library_id |
541 |
} |
542 |
); |
536 |
} |
543 |
} |
537 |
catch { |
544 |
catch { |
|
|
545 |
|
546 |
if ( blessed $_ and $_->isa('Koha::Exceptions::Hold::InvalidPickupLocation') ) { |
547 |
return $c->render( |
548 |
status => 400, |
549 |
openapi => { |
550 |
error => "$_" |
551 |
} |
552 |
); |
553 |
} |
554 |
|
538 |
$c->unhandled_exception($_); |
555 |
$c->unhandled_exception($_); |
539 |
}; |
556 |
}; |
540 |
} |
557 |
} |