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

(-)a/Koha/REST/V1/Reserve.pm (-1 / +1 lines)
Lines 1-4 Link Here
1
package Koha::REST::V1::Reserve;
1
package Koha::REST::V1::Hold;
2
2
3
# This file is part of Koha.
3
# This file is part of Koha.
4
#
4
#
(-)a/api/v1/definitions/reserve.json (-7 / +7 lines)
Lines 2-15 Link Here
2
    "type": "object",
2
    "type": "object",
3
    "properties": {
3
    "properties": {
4
        "reserve_id": {
4
        "reserve_id": {
5
            "description": "Internal reserve identifier"
5
            "description": "Internal hold identifier"
6
        },
6
        },
7
        "borrowernumber": {
7
        "borrowernumber": {
8
            "type": "string",
8
            "type": "string",
9
            "description": "internally assigned user identifier"
9
            "description": "internally assigned user identifier"
10
        },
10
        },
11
        "reservedate": {
11
        "reservedate": {
12
            "description": "the date the reserve was placed"
12
            "description": "the date the hold was placed"
13
        },
13
        },
14
        "biblionumber": {
14
        "biblionumber": {
15
            "type": "string",
15
            "type": "string",
Lines 26-44 Link Here
26
            "description": "currently unused"
26
            "description": "currently unused"
27
        },
27
        },
28
        "cancellationdate": {
28
        "cancellationdate": {
29
            "description": "the date the reserve was cancelled"
29
            "description": "the date the hold was cancelled"
30
        },
30
        },
31
        "reservenotes": {
31
        "reservenotes": {
32
            "description": "notes related to this reserve"
32
            "description": "notes related to this hold"
33
        },
33
        },
34
        "priority": {
34
        "priority": {
35
            "description": "where in the queue the patron sits"
35
            "description": "where in the queue the patron sits"
36
        },
36
        },
37
        "found": {
37
        "found": {
38
            "description": "a one letter code defining what the status of the reserve is after it has been confirmed"
38
            "description": "a one letter code defining what the status of the hold is after it has been confirmed"
39
        },
39
        },
40
        "timestamp": {
40
        "timestamp": {
41
            "description": "date and time the reserve was last updated"
41
            "description": "date and time the hold was last updated"
42
        },
42
        },
43
        "itemnumber": {
43
        "itemnumber": {
44
            "type": ["string", "null"],
44
            "type": ["string", "null"],
Lines 48-54 Link Here
48
            "description": "the date the item was marked as waiting for the patron at the library"
48
            "description": "the date the item was marked as waiting for the patron at the library"
49
        },
49
        },
50
        "expirationdate": {
50
        "expirationdate": {
51
            "description": "the date the reserve expires"
51
            "description": "the date the hold expires"
52
        },
52
        },
53
        "lowestPriority": {
53
        "lowestPriority": {
54
            "description": ""
54
            "description": ""
(-)a/api/v1/definitions/holds.json (+4 lines)
Line 0 Link Here
1
{
2
    "type": "array",
3
    "items": { "$ref": "hold.json" }
4
}
(-)a/api/v1/definitions/index.json (-2 / +2 lines)
Lines 1-6 Link Here
1
{
1
{
2
    "patron": { "$ref": "patron.json" },
2
    "patron": { "$ref": "patron.json" },
3
    "reserves": { "$ref": "reserves.json" },
3
    "holds": { "$ref": "holds.json" },
4
    "reserve": { "$ref": "reserve.json" },
4
    "hold": { "$ref": "hold.json" },
5
    "error": { "$ref": "error.json" }
5
    "error": { "$ref": "error.json" }
6
}
6
}
(-)a/api/v1/definitions/reserves.json (-4 lines)
Lines 1-4 Link Here
1
{
2
    "type": "array",
3
    "items": { "$ref": "reserve.json" }
4
}
(-)a/api/v1/swagger.json (-25 / +25 lines)
Lines 74-83 Link Here
74
        }
74
        }
75
      }
75
      }
76
    },
76
    },
77
    "/reserves": {
77
    "/holds": {
78
      "get": {
78
      "get": {
79
        "operationId": "listReserves",
79
        "operationId": "listHolds",
80
        "tags": ["borrowers", "reserves"],
80
        "tags": ["borrowers", "holds"],
81
        "parameters": [
81
        "parameters": [
82
          {
82
          {
83
            "name": "borrowernumber",
83
            "name": "borrowernumber",
Lines 90-97 Link Here
90
        "produces": ["application/json"],
90
        "produces": ["application/json"],
91
        "responses": {
91
        "responses": {
92
          "200": {
92
          "200": {
93
            "description": "A list of reserves",
93
            "description": "A list of holds",
94
            "schema": { "$ref": "#/definitions/reserves" }
94
            "schema": { "$ref": "#/definitions/holds" }
95
          },
95
          },
96
          "404": {
96
          "404": {
97
            "description": "Borrower not found",
97
            "description": "Borrower not found",
Lines 100-112 Link Here
100
        }
100
        }
101
      },
101
      },
102
      "post": {
102
      "post": {
103
        "operationId": "addReserve",
103
        "operationId": "addHold",
104
        "tags": ["borrowers", "reserves"],
104
        "tags": ["borrowers", "holds"],
105
        "parameters": [
105
        "parameters": [
106
          {
106
          {
107
            "name": "body",
107
            "name": "body",
108
            "in": "body",
108
            "in": "body",
109
            "description": "A JSON object containing informations about the new reserve",
109
            "description": "A JSON object containing informations about the new hold",
110
            "required": true,
110
            "required": true,
111
            "schema": {
111
            "schema": {
112
              "type": "object",
112
              "type": "object",
Lines 128-134 Link Here
128
                  "type": "string"
128
                  "type": "string"
129
                },
129
                },
130
                "expirationdate": {
130
                "expirationdate": {
131
                  "description": "Reserve end date",
131
                  "description": "Hold end date",
132
                  "type": "string",
132
                  "type": "string",
133
                  "format": "date"
133
                  "format": "date"
134
                }
134
                }
Lines 140-154 Link Here
140
        "produces": ["application/json"],
140
        "produces": ["application/json"],
141
        "responses": {
141
        "responses": {
142
          "201": {
142
          "201": {
143
            "description": "Created reserve",
143
            "description": "Created hold",
144
            "schema": { "$ref": "#/definitions/reserve" }
144
            "schema": { "$ref": "#/definitions/hold" }
145
          },
145
          },
146
          "400": {
146
          "400": {
147
            "description": "Missing or wrong parameters",
147
            "description": "Missing or wrong parameters",
148
            "schema": { "$ref": "#/definitions/error" }
148
            "schema": { "$ref": "#/definitions/error" }
149
          },
149
          },
150
          "403": {
150
          "403": {
151
            "description": "Reserve not allowed",
151
            "description": "Hold not allowed",
152
            "schema": { "$ref": "#/definitions/error" }
152
            "schema": { "$ref": "#/definitions/error" }
153
          },
153
          },
154
          "404": {
154
          "404": {
Lines 162-173 Link Here
162
        }
162
        }
163
      }
163
      }
164
    },
164
    },
165
    "/reserves/{reserve_id}": {
165
    "/holds/{reserve_id}": {
166
      "put": {
166
      "put": {
167
        "operationId": "editReserve",
167
        "operationId": "editHold",
168
        "tags": ["reserves"],
168
        "tags": ["holds"],
169
        "parameters": [
169
        "parameters": [
170
          { "$ref": "#/parameters/reserveIdPathParam" },
170
          { "$ref": "#/parameters/holdIdPathParam" },
171
          {
171
          {
172
            "name": "body",
172
            "name": "body",
173
            "in": "body",
173
            "in": "body",
Lines 198-221 Link Here
198
        "produces": ["application/json"],
198
        "produces": ["application/json"],
199
        "responses": {
199
        "responses": {
200
          "200": {
200
          "200": {
201
            "description": "Updated reserve",
201
            "description": "Updated hold",
202
            "schema": { "$ref": "#/definitions/reserve" }
202
            "schema": { "$ref": "#/definitions/hold" }
203
          },
203
          },
204
          "400": {
204
          "400": {
205
            "description": "Missing or wrong parameters",
205
            "description": "Missing or wrong parameters",
206
            "schema": { "$ref": "#/definitions/error" }
206
            "schema": { "$ref": "#/definitions/error" }
207
          },
207
          },
208
          "404": {
208
          "404": {
209
            "description": "Reserve not found",
209
            "description": "Hold not found",
210
            "schema": { "$ref": "#/definitions/error" }
210
            "schema": { "$ref": "#/definitions/error" }
211
          }
211
          }
212
        }
212
        }
213
      },
213
      },
214
      "delete": {
214
      "delete": {
215
        "operationId": "deleteReserve",
215
        "operationId": "deleteHold",
216
        "tags": ["reserves"],
216
        "tags": ["holds"],
217
        "parameters": [
217
        "parameters": [
218
          { "$ref": "#/parameters/reserveIdPathParam" }
218
          { "$ref": "#/parameters/holdIdPathParam" }
219
        ],
219
        ],
220
        "produces": ["application/json"],
220
        "produces": ["application/json"],
221
        "responses": {
221
        "responses": {
Lines 226-232 Link Here
226
            }
226
            }
227
          },
227
          },
228
          "404": {
228
          "404": {
229
            "description": "Reserve not found",
229
            "description": "Hold not found",
230
            "schema": { "$ref": "#/definitions/error" }
230
            "schema": { "$ref": "#/definitions/error" }
231
          }
231
          }
232
        }
232
        }
Lines 244-253 Link Here
244
      "required": true,
244
      "required": true,
245
      "type": "integer"
245
      "type": "integer"
246
    },
246
    },
247
    "reserveIdPathParam": {
247
    "holdIdPathParam": {
248
      "name": "reserve_id",
248
      "name": "reserve_id",
249
      "in": "path",
249
      "in": "path",
250
      "description": "Internal reserve identifier",
250
      "description": "Internal hold identifier",
251
      "required": true,
251
      "required": true,
252
      "type": "integer"
252
      "type": "integer"
253
    }
253
    }
(-)a/t/db_dependent/api/v1/reserves.t (-10 / +9 lines)
Lines 68-97 my $put_data = { Link Here
68
    priority => 2,
68
    priority => 2,
69
    suspend_until => $suspend_until,
69
    suspend_until => $suspend_until,
70
};
70
};
71
$t->put_ok("/api/v1/reserves/$reserve_id" => json => $put_data)
71
$t->put_ok("/api/v1/holds/$reserve_id" => json => $put_data)
72
  ->status_is(200)
72
  ->status_is(200)
73
  ->json_is('/reserve_id', $reserve_id)
73
  ->json_is('/reserve_id', $reserve_id)
74
  ->json_is('/suspend_until', $suspend_until . ' 00:00:00')
74
  ->json_is('/suspend_until', $suspend_until . ' 00:00:00')
75
  ->json_is('/priority', 2);
75
  ->json_is('/priority', 2);
76
76
77
$t->delete_ok("/api/v1/reserves/$reserve_id")
77
$t->delete_ok("/api/v1/holds/$reserve_id")
78
  ->status_is(200);
78
  ->status_is(200);
79
79
80
$t->put_ok("/api/v1/reserves/$reserve_id" => json => $put_data)
80
$t->put_ok("/api/v1/holds/$reserve_id" => json => $put_data)
81
  ->status_is(404)
81
  ->status_is(404)
82
  ->json_has('/error');
82
  ->json_has('/error');
83
83
84
$t->delete_ok("/api/v1/reserves/$reserve_id")
84
$t->delete_ok("/api/v1/holds/$reserve_id")
85
  ->status_is(404)
85
  ->status_is(404)
86
  ->json_has('/error');
86
  ->json_has('/error');
87
87
88
88
89
$t->get_ok("/api/v1/reserves?borrowernumber=$borrowernumber")
89
$t->get_ok("/api/v1/holds?borrowernumber=$borrowernumber")
90
  ->status_is(200)
90
  ->status_is(200)
91
  ->json_is([]);
91
  ->json_is([]);
92
92
93
my $inexisting_borrowernumber = $borrowernumber2 + 1;
93
my $inexisting_borrowernumber = $borrowernumber2 + 1;
94
$t->get_ok("/api/v1/reserves?borrowernumber=$inexisting_borrowernumber")
94
$t->get_ok("/api/v1/holds?borrowernumber=$inexisting_borrowernumber")
95
  ->status_is(404)
95
  ->status_is(404)
96
  ->json_has('/error');
96
  ->json_has('/error');
97
97
Lines 109-127 my $post_data = { Link Here
109
    branchcode => $branchcode,
109
    branchcode => $branchcode,
110
    expirationdate => $expirationdate,
110
    expirationdate => $expirationdate,
111
};
111
};
112
$t->post_ok("/api/v1/reserves" => json => $post_data)
112
$t->post_ok("/api/v1/holds" => json => $post_data)
113
  ->status_is(201)
113
  ->status_is(201)
114
  ->json_has('/reserve_id');
114
  ->json_has('/reserve_id');
115
115
116
$reserve_id = $t->tx->res->json->{reserve_id};
116
$reserve_id = $t->tx->res->json->{reserve_id};
117
117
118
$t->get_ok("/api/v1/reserves?borrowernumber=$borrowernumber")
118
$t->get_ok("/api/v1/holds?borrowernumber=$borrowernumber")
119
  ->status_is(200)
119
  ->status_is(200)
120
  ->json_is('/0/reserve_id', $reserve_id)
120
  ->json_is('/0/reserve_id', $reserve_id)
121
  ->json_is('/0/expirationdate', $expirationdate)
121
  ->json_is('/0/expirationdate', $expirationdate)
122
  ->json_is('/0/branchcode', $branchcode);
122
  ->json_is('/0/branchcode', $branchcode);
123
123
124
$t->post_ok("/api/v1/reserves" => json => $post_data)
124
$t->post_ok("/api/v1/holds" => json => $post_data)
125
  ->status_is(403)
125
  ->status_is(403)
126
  ->json_like('/error', qr/tooManyReserves/);
126
  ->json_like('/error', qr/tooManyReserves/);
127
127
128
- 

Return to bug 13903