Browse Source

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 <jweaver@bywatersolutions.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
16.05.x
Julian Maurice 8 years ago
committed by Kyle M Hall
parent
commit
9d31efa2b5
  1. 2
      Koha/REST/V1/Hold.pm
  2. 14
      api/v1/definitions/hold.json
  3. 4
      api/v1/definitions/holds.json
  4. 4
      api/v1/definitions/index.json
  5. 4
      api/v1/definitions/reserves.json
  6. 50
      api/v1/swagger.json
  7. 18
      t/db_dependent/api/v1/holds.t

2
Koha/REST/V1/Reserve.pm → 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.
#

14
api/v1/definitions/reserve.json → 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": ""

4
api/v1/definitions/holds.json

@ -0,0 +1,4 @@
{
"type": "array",
"items": { "$ref": "hold.json" }
}

4
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" }
}

4
api/v1/definitions/reserves.json

@ -1,4 +0,0 @@
{
"type": "array",
"items": { "$ref": "reserve.json" }
}

50
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"
}

18
t/db_dependent/api/v1/reserves.t → 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/);
Loading…
Cancel
Save