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

(-)a/Koha/REST/V1/Holds.pm (-3 / +20 lines)
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
}
(-)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