REST API documentation - Rumec/pb138-project GitHub Wiki
Note: All requests require X-User header
with value of user ID else 401 Unauthorized
(except /api/user/login
and /api/user/registration
)
GET components by category
-
Retrieves components of all types (+ filtered by category)
- returns an object containing the following arrays: cpu, motherboard, ram, disk, gpu, psu, case, screen, keyboard, mouse
-
/api/components/{category}
-
category required
-
Errors:
- category not provided -> 400 Bad Request with status message "Component category is not defined in the URL."
-
Output format:
{
cpu: [ {cpu1}, {cpu2}, ...],
gpu: [ {gpu1}, {gpu2}, ... ],
case: [ {case1}, {case2}], ...,
...
}
GET all components
- Retrieves all components of all types
- returns an object containing the following arrays: cpu, motherboard, ram, disk, gpu, psu, case, monitor, keyboard, mouse
/api/components
- Errors:
- none
- Output format:
{
cpu: [ {cpu1}, {cpu2}, ...],
gpu: [ {gpu1}, {gpu2}, ... ],
case: [ {case1}, {case2}], ...,
...
}
GET orders
- Loads all orders of current user or only specific number of latest orders if query parameter orderCount is provided.
/api/orders?orderCount={count}
- orderCount optional
POST user login
- Logs in a user (checks credentials and returns user object from database by username if password matches)
/api/user/login?username={username}&password={password}
- Errors:
- username and password required (else HTTP
400 Bad Request
) - user with username does not exist -> HTTP
404 Not Found
- password mismatch -> HTTP
401 Unauthorized
- username and password required (else HTTP
POST user registration
- Registers a new user and returns user object (newly created in the database)
/api/user/registration?username={username}&password={password}&passwordConfirm={passwordConfirm}
- Errors:
- username, password and passwordConfirm are required (else HTTP
400 Bad Request
) - user with username already exists -> HTTP
409 Conflict
- _password _and passwordConfirm mismatch -> HTTP
422 Unprocessable Entity
- username, password and passwordConfirm are required (else HTTP
GET order for recapitulation (with all components included and computer with alll components included)
/api/orders/{id}
- TODO fill documentation from JSdoc in code
PUT cancel order
/api/orders/{id}
- TODO fill documentation from JSdoc in code