The main goal of this task is to practice the use of Flask framework and to write/load data using JSON file type to storage data.
.
- /user -> list all users (GET)
- /user/:id -> filter user (GET)
- /user -> register new user (POST)
- /user/:id -> update user's data (PATCH)
- /user/:id -> delete user (DELETE)
GET /user
No request body needed.
In case everything works well, the answer shall be like:
STATUS 200
{
"data": [
{
"email": "name@mail.com",
"id": 1,
"name": "Name"
},
{
"email": "name@mail.com",
"id": 2,
"name": "Name"
}
]
}
GET /user/:id
No request body needed.
In case everything works well, the answer shall be like:
STATUS 200
{
"email": "name@mail.com",
"id": 1,
"name": "Name"
},
Possible errors:
1.- User not found (STATUS 404)
POST /user
{
"name": "Name",
"email": "name@mail.com"
}
In case everything works well, the answer shall be like:
STATUS 201
{
"email": "name@mail.com",
"id": 1,
"name": "Name"
}
Possible errors:
1.- E-mail or name not of string type (STATUS 400)
2.- E-mail already registered (STATUS 409)
3.- Wrong keys error (STATUS 400)
It is allowed to change name and/or e-mail data from user.
PATCH /user/:id
{
"name": "New Name",
"email": "newmail@mail.com"
}
or only name/email alone.
In case everything works well, the answer shall be like:
STATUS 200
{
"email": "newmail@mail.com",
"id": 1,
"name": "New Name"
}
Possible errors:
1.- E-mail or name not of string type (STATUS 400)
2.- E-mail already registered (STATUS 409)
3.- Wrong keys error (STATUS 400)
4.- User not found (STATUS 404)
The user data can be deleted.
DELETE /user/:id
No request body needed.
In case everything works well, the answer shall be like:
STATUS 200
{
"email": "mail@mail.com",
"id": 1,
"name": "Name"
}
Possible errors:
1.- User not found (STATUS 404)