From 30e87a88e0ff5a4ad6c8052b28722f6ccf1df011 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Tue, 24 Mar 2015 11:30:00 +0100 Subject: [PATCH] Bug 13903: (QA followup) change routes to /holds GET /holds?borrowernumber=X (list) POST /holds (create) PUT /holds/{reserve_id} (update) DELETE /holds/{reserve_id} (delete) Unit tests in t/db_dependent/api/v1/holds.t Signed-off-by: Jesse Weaver --- Koha/REST/V1/{Reserve.pm => Hold.pm} | 2 +- api/v1/definitions/{reserve.json => hold.json} | 14 ++++---- api/v1/definitions/holds.json | 4 +++ api/v1/definitions/index.json | 4 +-- api/v1/definitions/reserves.json | 4 --- api/v1/swagger.json | 50 +++++++++++++------------- t/db_dependent/api/v1/{reserves.t => holds.t} | 18 +++++----- 7 files changed, 48 insertions(+), 48 deletions(-) rename Koha/REST/V1/{Reserve.pm => Hold.pm} (99%) rename api/v1/definitions/{reserve.json => hold.json} (78%) create mode 100644 api/v1/definitions/holds.json delete mode 100644 api/v1/definitions/reserves.json rename t/db_dependent/api/v1/{reserves.t => holds.t} (88%) diff --git a/Koha/REST/V1/Reserve.pm b/Koha/REST/V1/Hold.pm similarity index 99% rename from Koha/REST/V1/Reserve.pm rename to Koha/REST/V1/Hold.pm index 69e6e98..208488d 100644 --- a/Koha/REST/V1/Reserve.pm +++ b/Koha/REST/V1/Hold.pm @@ -1,4 +1,4 @@ -package Koha::REST::V1::Reserve; +package Koha::REST::V1::Hold; # This file is part of Koha. # diff --git a/api/v1/definitions/reserve.json b/api/v1/definitions/hold.json similarity index 78% rename from api/v1/definitions/reserve.json rename to api/v1/definitions/hold.json index 74370fe..17bc834 100644 --- a/api/v1/definitions/reserve.json +++ b/api/v1/definitions/hold.json @@ -2,14 +2,14 @@ "type": "object", "properties": { "reserve_id": { - "description": "Internal reserve identifier" + "description": "Internal hold identifier" }, "borrowernumber": { "type": "string", "description": "internally assigned user identifier" }, "reservedate": { - "description": "the date the reserve was placed" + "description": "the date the hold was placed" }, "biblionumber": { "type": "string", @@ -26,19 +26,19 @@ "description": "currently unused" }, "cancellationdate": { - "description": "the date the reserve was cancelled" + "description": "the date the hold was cancelled" }, "reservenotes": { - "description": "notes related to this reserve" + "description": "notes related to this hold" }, "priority": { "description": "where in the queue the patron sits" }, "found": { - "description": "a one letter code defining what the status of the reserve is after it has been confirmed" + "description": "a one letter code defining what the status of the hold is after it has been confirmed" }, "timestamp": { - "description": "date and time the reserve was last updated" + "description": "date and time the hold was last updated" }, "itemnumber": { "type": ["string", "null"], @@ -48,7 +48,7 @@ "description": "the date the item was marked as waiting for the patron at the library" }, "expirationdate": { - "description": "the date the reserve expires" + "description": "the date the hold expires" }, "lowestPriority": { "description": "" diff --git a/api/v1/definitions/holds.json b/api/v1/definitions/holds.json new file mode 100644 index 0000000..6d64441 --- /dev/null +++ b/api/v1/definitions/holds.json @@ -0,0 +1,4 @@ +{ + "type": "array", + "items": { "$ref": "hold.json" } +} diff --git a/api/v1/definitions/index.json b/api/v1/definitions/index.json index 4e17693..3f69544 100644 --- a/api/v1/definitions/index.json +++ b/api/v1/definitions/index.json @@ -1,6 +1,6 @@ { "patron": { "$ref": "patron.json" }, - "reserves": { "$ref": "reserves.json" }, - "reserve": { "$ref": "reserve.json" }, + "holds": { "$ref": "holds.json" }, + "hold": { "$ref": "hold.json" }, "error": { "$ref": "error.json" } } diff --git a/api/v1/definitions/reserves.json b/api/v1/definitions/reserves.json deleted file mode 100644 index 431c444..0000000 --- a/api/v1/definitions/reserves.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "type": "array", - "items": { "$ref": "reserve.json" } -} diff --git a/api/v1/swagger.json b/api/v1/swagger.json index b5c6d0a..1488aba 100644 --- a/api/v1/swagger.json +++ b/api/v1/swagger.json @@ -74,10 +74,10 @@ } } }, - "/reserves": { + "/holds": { "get": { - "operationId": "listReserves", - "tags": ["borrowers", "reserves"], + "operationId": "listHolds", + "tags": ["borrowers", "holds"], "parameters": [ { "name": "borrowernumber", @@ -90,8 +90,8 @@ "produces": ["application/json"], "responses": { "200": { - "description": "A list of reserves", - "schema": { "$ref": "#/definitions/reserves" } + "description": "A list of holds", + "schema": { "$ref": "#/definitions/holds" } }, "404": { "description": "Borrower not found", @@ -100,13 +100,13 @@ } }, "post": { - "operationId": "addReserve", - "tags": ["borrowers", "reserves"], + "operationId": "addHold", + "tags": ["borrowers", "holds"], "parameters": [ { "name": "body", "in": "body", - "description": "A JSON object containing informations about the new reserve", + "description": "A JSON object containing informations about the new hold", "required": true, "schema": { "type": "object", @@ -128,7 +128,7 @@ "type": "string" }, "expirationdate": { - "description": "Reserve end date", + "description": "Hold end date", "type": "string", "format": "date" } @@ -140,15 +140,15 @@ "produces": ["application/json"], "responses": { "201": { - "description": "Created reserve", - "schema": { "$ref": "#/definitions/reserve" } + "description": "Created hold", + "schema": { "$ref": "#/definitions/hold" } }, "400": { "description": "Missing or wrong parameters", "schema": { "$ref": "#/definitions/error" } }, "403": { - "description": "Reserve not allowed", + "description": "Hold not allowed", "schema": { "$ref": "#/definitions/error" } }, "404": { @@ -162,12 +162,12 @@ } } }, - "/reserves/{reserve_id}": { + "/holds/{reserve_id}": { "put": { - "operationId": "editReserve", - "tags": ["reserves"], + "operationId": "editHold", + "tags": ["holds"], "parameters": [ - { "$ref": "#/parameters/reserveIdPathParam" }, + { "$ref": "#/parameters/holdIdPathParam" }, { "name": "body", "in": "body", @@ -198,24 +198,24 @@ "produces": ["application/json"], "responses": { "200": { - "description": "Updated reserve", - "schema": { "$ref": "#/definitions/reserve" } + "description": "Updated hold", + "schema": { "$ref": "#/definitions/hold" } }, "400": { "description": "Missing or wrong parameters", "schema": { "$ref": "#/definitions/error" } }, "404": { - "description": "Reserve not found", + "description": "Hold not found", "schema": { "$ref": "#/definitions/error" } } } }, "delete": { - "operationId": "deleteReserve", - "tags": ["reserves"], + "operationId": "deleteHold", + "tags": ["holds"], "parameters": [ - { "$ref": "#/parameters/reserveIdPathParam" } + { "$ref": "#/parameters/holdIdPathParam" } ], "produces": ["application/json"], "responses": { @@ -226,7 +226,7 @@ } }, "404": { - "description": "Reserve not found", + "description": "Hold not found", "schema": { "$ref": "#/definitions/error" } } } @@ -244,10 +244,10 @@ "required": true, "type": "integer" }, - "reserveIdPathParam": { + "holdIdPathParam": { "name": "reserve_id", "in": "path", - "description": "Internal reserve identifier", + "description": "Internal hold identifier", "required": true, "type": "integer" } diff --git a/t/db_dependent/api/v1/reserves.t b/t/db_dependent/api/v1/holds.t similarity index 88% rename from t/db_dependent/api/v1/reserves.t rename to t/db_dependent/api/v1/holds.t index eeccbfd..0ce67d5 100644 --- a/t/db_dependent/api/v1/reserves.t +++ b/t/db_dependent/api/v1/holds.t @@ -68,30 +68,30 @@ my $put_data = { priority => 2, suspend_until => $suspend_until, }; -$t->put_ok("/api/v1/reserves/$reserve_id" => json => $put_data) +$t->put_ok("/api/v1/holds/$reserve_id" => json => $put_data) ->status_is(200) ->json_is('/reserve_id', $reserve_id) ->json_is('/suspend_until', $suspend_until . ' 00:00:00') ->json_is('/priority', 2); -$t->delete_ok("/api/v1/reserves/$reserve_id") +$t->delete_ok("/api/v1/holds/$reserve_id") ->status_is(200); -$t->put_ok("/api/v1/reserves/$reserve_id" => json => $put_data) +$t->put_ok("/api/v1/holds/$reserve_id" => json => $put_data) ->status_is(404) ->json_has('/error'); -$t->delete_ok("/api/v1/reserves/$reserve_id") +$t->delete_ok("/api/v1/holds/$reserve_id") ->status_is(404) ->json_has('/error'); -$t->get_ok("/api/v1/reserves?borrowernumber=$borrowernumber") +$t->get_ok("/api/v1/holds?borrowernumber=$borrowernumber") ->status_is(200) ->json_is([]); my $inexisting_borrowernumber = $borrowernumber2 + 1; -$t->get_ok("/api/v1/reserves?borrowernumber=$inexisting_borrowernumber") +$t->get_ok("/api/v1/holds?borrowernumber=$inexisting_borrowernumber") ->status_is(404) ->json_has('/error'); @@ -109,19 +109,19 @@ my $post_data = { branchcode => $branchcode, expirationdate => $expirationdate, }; -$t->post_ok("/api/v1/reserves" => json => $post_data) +$t->post_ok("/api/v1/holds" => json => $post_data) ->status_is(201) ->json_has('/reserve_id'); $reserve_id = $t->tx->res->json->{reserve_id}; -$t->get_ok("/api/v1/reserves?borrowernumber=$borrowernumber") +$t->get_ok("/api/v1/holds?borrowernumber=$borrowernumber") ->status_is(200) ->json_is('/0/reserve_id', $reserve_id) ->json_is('/0/expirationdate', $expirationdate) ->json_is('/0/branchcode', $branchcode); -$t->post_ok("/api/v1/reserves" => json => $post_data) +$t->post_ok("/api/v1/holds" => json => $post_data) ->status_is(403) ->json_like('/error', qr/tooManyReserves/); -- 2.8.0.rc3