View | Details | Raw Unified | Return to bug 18729
Collapse All | Expand All

(-)a/Koha/REST/V1/Holds.pm (-3 / +20 lines)
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
}
(-)a/api/v1/swagger/paths/holds.json (-3 / +20 lines)
Lines 692-698 Link Here
692
          "description": "Pickup location",
692
          "description": "Pickup location",
693
          "required": true,
693
          "required": true,
694
          "schema": {
694
          "schema": {
695
            "type": "string"
695
            "type": "object",
696
            "properties": {
697
              "pickup_library_id": {
698
                "type": "string",
699
                "description": "Internal identifier for the pickup library"
700
              }
701
            }
696
          }
702
          }
697
        }
703
        }
698
      ],
704
      ],
Lines 703-709 Link Here
703
        "200": {
709
        "200": {
704
          "description": "The new pickup location value for the hold",
710
          "description": "The new pickup location value for the hold",
705
          "schema": {
711
          "schema": {
706
            "type": "string"
712
            "type": "object",
713
            "properties": {
714
              "pickup_library_id": {
715
                "type": "string",
716
                "description": "Internal identifier for the pickup library"
717
              }
718
            }
719
          }
720
        },
721
        "400": {
722
          "description": "Missing or wrong parameters",
723
          "schema": {
724
            "$ref": "../definitions.json#/error"
707
          }
725
          }
708
        },
726
        },
709
        "401": {
727
        "401": {
710
- 

Return to bug 18729