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