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

(-)a/Koha/REST/V1/Holds.pm (-3 / +20 lines)
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
}
(-)a/api/v1/swagger/paths/holds.json (-3 / +20 lines)
Lines 718-724 Link Here
718
          "description": "Pickup location",
718
          "description": "Pickup location",
719
          "required": true,
719
          "required": true,
720
          "schema": {
720
          "schema": {
721
            "type": "string"
721
            "type": "object",
722
            "properties": {
723
              "pickup_library_id": {
724
                "type": "string",
725
                "description": "Internal identifier for the pickup library"
726
              }
727
            }
722
          }
728
          }
723
        }
729
        }
724
      ],
730
      ],
Lines 729-735 Link Here
729
        "200": {
735
        "200": {
730
          "description": "The new pickup location value for the hold",
736
          "description": "The new pickup location value for the hold",
731
          "schema": {
737
          "schema": {
732
            "type": "string"
738
            "type": "object",
739
            "properties": {
740
              "pickup_library_id": {
741
                "type": "string",
742
                "description": "Internal identifier for the pickup library"
743
              }
744
            }
745
          }
746
        },
747
        "400": {
748
          "description": "Missing or wrong parameters",
749
          "schema": {
750
            "$ref": "../definitions.json#/error"
733
          }
751
          }
734
        },
752
        },
735
        "401": {
753
        "401": {
736
- 

Return to bug 18729