Bug 30660: Add cancellation reason to holds delete endpoint

This patch adds cancellation reason to holds delete endpoint.

Test plan:
1) prove t/db_dependent/api/v1/holds.t

PA amended: tidy

Sponsored-by: Koha-Suomi Oy
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Johanna Raisa 2022-05-02 11:49:11 +03:00 committed by Katrin Fischer
parent 3fac0dc36f
commit a50eacf11d
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
3 changed files with 9 additions and 2 deletions

View File

@ -328,7 +328,8 @@ sub delete {
);
}
$hold->cancel;
my $cancellation_reason = $c->req->json;
$hold->cancel( { cancellation_reason => $cancellation_reason } );
return $c->render_resource_deleted;
}

View File

@ -403,6 +403,12 @@
summary: Cancel hold
parameters:
- $ref: "../swagger.yaml#/parameters/hold_id_pp"
- name: body
in: body
description: Cancellation reason
required: false
schema:
type: string
- name: x-koha-override
in: header
required: false

View File

@ -234,7 +234,7 @@ subtest "Test endpoints with permission" => sub {
->status_is(200)
->json_is([]);
$t->delete_ok( "//$userid_3:$password@/api/v1/holds/$reserve_id2" )
$t->delete_ok( "//$userid_3:$password@/api/v1/holds/$reserve_id2" => json => "Cancellation reason" )
->status_is(204, 'SWAGGER3.2.4')
->content_is('', 'SWAGGER3.3.4');