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

(-)a/Koha/REST/V1/Patrons/Holds.pm (+45 lines)
Lines 64-67 sub list { Link Here
64
    };
64
    };
65
}
65
}
66
66
67
68
=head3 delete_public
69
70
Controller function that handles cancelling a hold for the requested patron. Returns
71
a I<204> if cancelling took place, and I<202> if a cancellation request is recorded
72
instead.
73
74
=cut
75
76
sub delete_public {
77
    my $c = shift->openapi->valid_input or return;
78
79
    return try {
80
        my $hold = $c->objects->find_rs( Koha::Holds->new, $c->param('hold_id') );
81
82
        unless ( $hold and $c->param('patron_id') == $hold->borrowernumber ) {
83
            return $c->render(
84
                status  => 404,
85
                openapi => { error => 'Object not found' }
86
            );
87
        }
88
89
        if ( $hold->is_cancelable_from_opac ) {
90
            $hold->cancel;
91
            return $c->render(
92
                status  => 204,
93
                openapi => q{},
94
            );
95
        } elsif ( $hold->is_waiting and $hold->cancellation_requestable_from_opac ) {
96
            $hold->add_cancellation_request;
97
            return $c->render(
98
                status  => 202,
99
                openapi => q{},
100
            );
101
        } else {    # reject
102
            return $c->render(
103
                status  => 403,
104
                openapi => { error => 'Cancellation forbidden' }
105
            );
106
        }
107
    } catch {
108
        $c->unhandled_exception($_);
109
    };
110
}
111
67
1;
112
1;
(-)a/api/v1/swagger/paths/public_patrons.yaml (+46 lines)
Lines 170-172 Link Here
170
          $ref: "../swagger.yaml#/definitions/error"
170
          $ref: "../swagger.yaml#/definitions/error"
171
    x-koha-authorization:
171
    x-koha-authorization:
172
      allow-owner: true
172
      allow-owner: true
173
"/public/patrons/{patron_id}/holds/{hold_id}":
174
  delete:
175
    x-mojo-to: Patrons::Holds#delete_public
176
    operationId: cancelPatronHoldPublic
177
    tags:
178
      - patrons
179
    summary: Cancel a patron's hold (public)
180
    parameters:
181
      - $ref: "../swagger.yaml#/parameters/patron_id_pp"
182
      - $ref: "../swagger.yaml#/parameters/hold_id_pp"
183
    produces:
184
      - application/json
185
    responses:
186
      "202":
187
        description: Hold cancellation request accepted
188
      "204":
189
        description: Hold cancelled
190
      "400":
191
        description: Bad request
192
        schema:
193
          $ref: "../swagger.yaml#/definitions/error"
194
      "401":
195
        description: Authentication required
196
        schema:
197
          $ref: "../swagger.yaml#/definitions/error"
198
      "403":
199
        description: Access forbidden
200
        schema:
201
          $ref: "../swagger.yaml#/definitions/error"
202
      "404":
203
        description: Hold not found
204
        schema:
205
          $ref: "../swagger.yaml#/definitions/error"
206
      "500":
207
        description: |
208
          Internal server error. Possible `error_code` attribute values:
209
210
          * `internal_server_error`
211
        schema:
212
          $ref: "../swagger.yaml#/definitions/error"
213
      "503":
214
        description: Under maintenance
215
        schema:
216
          $ref: "../swagger.yaml#/definitions/error"
217
    x-koha-authorization:
218
      allow-owner: true
(-)a/api/v1/swagger/swagger.yaml (-1 / +2 lines)
Lines 325-330 paths: Link Here
325
    $ref: "./paths/public_patrons.yaml#/~1public~1patrons~1{patron_id}~1guarantors~1can_see_charges"
325
    $ref: "./paths/public_patrons.yaml#/~1public~1patrons~1{patron_id}~1guarantors~1can_see_charges"
326
  "/public/patrons/{patron_id}/guarantors/can_see_checkouts":
326
  "/public/patrons/{patron_id}/guarantors/can_see_checkouts":
327
    $ref: "./paths/public_patrons.yaml#/~1public~1patrons~1{patron_id}~1guarantors~1can_see_checkouts"
327
    $ref: "./paths/public_patrons.yaml#/~1public~1patrons~1{patron_id}~1guarantors~1can_see_checkouts"
328
  "/public/patrons/{patron_id}/holds/{hold_id}":
329
    $ref: "./paths/public_patrons.yaml#/~1public~1patrons~1{patron_id}~1holds~1{hold_id}"
328
  "/public/patrons/{patron_id}/password":
330
  "/public/patrons/{patron_id}/password":
329
    $ref: "./paths/public_patrons.yaml#/~1public~1patrons~1{patron_id}~1password"
331
    $ref: "./paths/public_patrons.yaml#/~1public~1patrons~1{patron_id}~1password"
330
  "/public/tickets":
332
  "/public/tickets":
331
- 

Return to bug 33573