From a7d296d652554accf2532d35db75be544c78a11f Mon Sep 17 00:00:00 2001 From: Johanna Raisa Date: Mon, 2 May 2022 11:49:11 +0300 Subject: [PATCH] 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 Sponsored-by: Koha-Suomi Oy --- Koha/REST/V1/Holds.pm | 3 ++- api/v1/swagger/paths/holds.yaml | 8 +++++++- t/db_dependent/api/v1/holds.t | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Koha/REST/V1/Holds.pm b/Koha/REST/V1/Holds.pm index 44188363a6..f0758b1b6c 100644 --- a/Koha/REST/V1/Holds.pm +++ b/Koha/REST/V1/Holds.pm @@ -315,7 +315,8 @@ sub delete { } return try { - $hold->cancel; + my $cancellation_reason = $c->req->json; + $hold->cancel({ cancellation_reason => $cancellation_reason }); return $c->render( status => 204, diff --git a/api/v1/swagger/paths/holds.yaml b/api/v1/swagger/paths/holds.yaml index 617eb3d9d3..d5dcdad119 100644 --- a/api/v1/swagger/paths/holds.yaml +++ b/api/v1/swagger/paths/holds.yaml @@ -370,7 +370,13 @@ - holds summary: Cancel hold parameters: - - $ref: "../swagger.yaml#/parameters/hold_id_pp" + - $ref: ../swagger.yaml#/hold_id_pp + - name: body + in: body + description: Cancellation reason + required: false + schema: + type: string produces: - application/json responses: diff --git a/t/db_dependent/api/v1/holds.t b/t/db_dependent/api/v1/holds.t index 6665b55116..773fb8d031 100755 --- a/t/db_dependent/api/v1/holds.t +++ b/t/db_dependent/api/v1/holds.t @@ -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'); -- 2.25.1