|
Lines 493-498
sub update_pickup_location {
Link Here
|
| 493 |
my $c = shift->openapi->valid_input or return; |
493 |
my $c = shift->openapi->valid_input or return; |
| 494 |
|
494 |
|
| 495 |
my $hold_id = $c->validation->param('hold_id'); |
495 |
my $hold_id = $c->validation->param('hold_id'); |
|
|
496 |
my $body = $c->validation->param('body'); |
| 497 |
my $pickup_library_id = $body->{pickup_library_id}; |
| 498 |
|
| 496 |
my $hold = Koha::Holds->find($hold_id); |
499 |
my $hold = Koha::Holds->find($hold_id); |
| 497 |
|
500 |
|
| 498 |
unless ($hold) { |
501 |
unless ($hold) { |
|
Lines 503-515
sub update_pickup_location {
Link Here
|
| 503 |
} |
506 |
} |
| 504 |
|
507 |
|
| 505 |
return try { |
508 |
return try { |
| 506 |
my $pickup_location = $c->req->json; |
|
|
| 507 |
|
509 |
|
| 508 |
$hold->branchcode($pickup_location)->store; |
510 |
$hold->set_pickup_location({ library_id => $pickup_library_id }); |
| 509 |
|
511 |
|
| 510 |
return $c->render( status => 200, openapi => $pickup_location ); |
512 |
return $c->render( |
|
|
513 |
status => 200, |
| 514 |
openapi => { |
| 515 |
pickup_library_id => $pickup_library_id |
| 516 |
} |
| 517 |
); |
| 511 |
} |
518 |
} |
| 512 |
catch { |
519 |
catch { |
|
|
520 |
|
| 521 |
if ( blessed $_ and $_->isa('Koha::Exceptions::Hold::InvalidPickupLocation') ) { |
| 522 |
return $c->render( |
| 523 |
status => 400, |
| 524 |
openapi => { |
| 525 |
error => "$_" |
| 526 |
} |
| 527 |
); |
| 528 |
} |
| 529 |
|
| 513 |
$c->unhandled_exception($_); |
530 |
$c->unhandled_exception($_); |
| 514 |
}; |
531 |
}; |
| 515 |
} |
532 |
} |