-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrequirements.html
More file actions
280 lines (252 loc) · 7.75 KB
/
requirements.html
File metadata and controls
280 lines (252 loc) · 7.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
<html>
<head>
<title>API Farm Reqs</title>
<style>
table, th, td {
border: 1px solid black;
}
th {
text-align: left;
}
</style>
</head>
<body style="font-family: Consolas;">
<h1>API Farm Requirements</h1>
<p>
Each endpoint for the API is listed below. Including its expected behaviour with given data.
</p>
<div>
<h2>GET /video_games</h2>
<p>
Retrieves all video games from storage and responded as an array in the body.
</p>
<div>
<h3>Examples</h3>
<div>
<h4>Request</h4>
<p>
Request of method type <code>GET</code> made to <code>/video_games</code> endpoint.
</p>
<h4>Response 200</h4>
<pre>
[
{
"name": "Perfect Dark",
...
},
{
"name": "Super Mario 64",
...
}
]
</pre>
</div>
</div>
</div>
<div>
<h2>GET /video_games/:id</h2>
<p>
Retrieves video game with specified id from storage and set as response body.
</p>
<div>
<h3>Examples</h3>
<div>
<h4>Request</h4>
<p>
Request of method type <code>GET</code> made to <code>/video_games/:id</code>, where the id is that of the desired video game.
</p>
<h4>Response 200</h4>
<pre>
{
"name": "Bomberman 64",
...
}
</pre>
<h4>Response 404</h4>
<pre>No video game with id 'x' could be found.</pre>
</div>
</div>
</div>
<div>
<h2>POST /video_games</h2>
<p>
Creates a video game within storage with the provided data from the request body. Failing to provide required or invalid data will result in
a bad request response. The table below shows what data is expected and its type.
</p>
<table style="width: 100%;">
<tr>
<th>Attribute</th>
<th>Type</th>
<th>Required?</th>
<th>Default Value</th>
<th>Description</th>
</tr>
<tr>
<td>name</td>
<td>string</td>
<td>yes</td>
<td>N/A</td>
<td>The name of the video game. This must be provided in the body of the request.</td>
</tr>
<tr>
<td>developers</td>
<td>string[]</td>
<td>no</td>
<td>[]</td>
<td>An array of the names of the developers who worked on the video game.</td>
</tr>
<tr>
<td>directors</td>
<td>string[]</td>
<td>no</td>
<td>[]</td>
<td>An array of the names of the people who directed the video game.</td>
</tr>
<tr>
<td>producers</td>
<td>string[]</td>
<td>no</td>
<td>[]</td>
<td>An array of the names of the people who produced the video game.</td>
</tr>
<tr>
<td>designers</td>
<td>string[]</td>
<td>no</td>
<td>[]</td>
<td>An array of the names of the people who designed the video game.</td>
</tr>
<tr>
<td>programmers</td>
<td>string[]</td>
<td>no</td>
<td>[]</td>
<td>An array of the names of the people who programmed the video game.</td>
</tr>
<tr>
<td>artists</td>
<td>string[]</td>
<td>no</td>
<td>[]</td>
<td>An array of the names of the people who worked on the art of the video game.</td>
</tr>
<tr>
<td>composers</td>
<td>string[]</td>
<td>no</td>
<td>[]</td>
<td>An array of the names of the people who composed the soundtrack of the video game.</td>
</tr>
<tr>
<td>platforms</td>
<td>string[]</td>
<td>no</td>
<td>[]</td>
<td>An array of the names of the platforms the video game had been released on.</td>
</tr>
<tr>
<td>date_released</td>
<td>string</td>
<td>yes</td>
<td>N/A</td>
<td>The date that the video game had been released. The date must be in the format 'DD/MM/YYYY'.</td>
</tr>
</table>
<div>
<h3>Examples</h3>
<div>
<h4>Request</h4>
<p>
Request of method type <code>POST</code> made to <code>/video_games</code>. The request body makes up the attributes of the new video game.
Below, is an example request;
</p>
<pre>
{
"name": "Banjo Kazooie",
"developers": [
"Rare",
],
"publishers": [
"Nintendo"
],
"directors": [
"Gregg Mayles",
"George Andreas"
],
"producers": [
"Tim Stamper",
"Chris Stamper"
],
"designers": [
"Gregg Mayles"
],
"programmers": [
"Chris Sutherland"
],
"artists": [
"Steve Mayles",
"John Nash",
"Kevin Bayliss",
"Tim Stamper"
],
"composers": [
"Grant Kirkhope"
],
"platforms": [
"Nintendo 64"
],
"date_released": "29/06/1998"
}
</pre>
<h4>Response 201</h4>
<pre>
{
"id": 3,
"name": "Banjo Kazooie",
"developers": [
"Rare",
],
"publishers": [
"Nintendo"
],
"directors": [
"Gregg Mayles",
"George Andreas"
],
"producers": [
"Tim Stamper",
"Chris Stamper"
],
"designers": [
"Gregg Mayles"
],
"programmers": [
"Chris Sutherland"
],
"artists": [
"Steve Mayles",
"John Nash",
"Kevin Bayliss",
"Tim Stamper"
],
"composers": [
"Grant Kirkhope"
],
"platforms": [
"Nintendo 64"
],
"date_released": "29/06/1998"
}
</pre>
<h4>Response 400</h4>
<p>
A bad request can be the result of either not providing a value for the <name>name</name> or <code>date_released</code>.
Additionally, a bad request can be responded when the provided <code>date_released</code> is invalid.
</p>
<pre>A name is required for a video game.</pre>
<pre>The provided date_released '29 June 1998' is invalid and must be in the format 'DD/MM/YYYY'.</pre>
</div>
</div>
</div>
</body>
</html>