View Code? Open in Web Editor
NEW
API creation for a student project.
p7's People
Contributors
Watchers
p7's Issues
The links are represented by a array, utilisation of an object.
Actually the output object in the outputItem are models, using output item for all output objects.
Example : Brand in OutputPhone is model.
Goal
As an Client connected, I need to be able to collect a details of one phone to the database.
Start
Client request to "/api/phones/{id}", with :
{id} : the phone ID
Bearer token in the headers of the Request
Method : GET
Technical contraints
The Client must be connected and he must send the Bearer token to the headers of the Request
The Client must have the phone ID. He can collect this ID in the phones list.
Scenarios
The Client has no token, bad token or expired token : Response 401 with the error content :
TOKEN_EXPIRED : "La durée de validité de votre Token est dépassée, veuillez vous reconnecter."
TOKEN_INVALID : "Votre Token de connexion est invalide, veuillez vous reconnecter."
NO_TOKEN : "Aucun Token de connexion n'a été trouvé, veuillez vous connecter."
The Client has a good token :
No phone founds in the database : Response 404 with the error content : "No phone found in the database, please check your input parameters."
Phone founds in the database : Response 200 with JSON array with phone in the Response content.
Diagrams
Physical model of data
Sequence diagram
Class diagram
To do
Using JWT to create an authentication service
Goal
As an Client connected, I need to be able to collect a details of one user to the database.
Start
Client request to "/api/client/{client}/users/{id}", with :
{client} : their Client ID
{id} : the user ID
Bearer token in the headers of the Request
Method : GET
Technical contraints
The Client must be connected and he must send the Bearer token to the headers of the Request
The Client must have the user ID. He can collect this ID in the users list.
Scenarios
The Client has no token, bad token or expired token : Response 401 with the error content :
TOKEN_EXPIRED : "La durée de validité de votre Token est dépassée, veuillez vous reconnecter."
TOKEN_INVALID : "Votre Token de connexion est invalide, veuillez vous reconnecter."
NO_TOKEN : "Aucun Token de connexion n'a été trouvé, veuillez vous connecter."
The Client has a good token :
No user founds in the database : Response 404 with the error content : "No user found in the database, please check your input parameters."
Users found in the database : Response 200 with JSON array with user in the Response content.
Diagrams
Physical model of data
Sequence diagram
Class diagram
To do
Goal
As an Client connected, I need to be able to collect a phones list to the database.
Start
Client request to "/api/phones", with :
Bearer token in the headers of the Request
Method : GET
Technical contraints
The Client must be connected and he must send the Bearer token to the headers of the Request
The Client can filtered the list with three parameters :
limit : number of phone collects to the database
offset : the first phone in the database
brand : the phone brand
Scenarios
The Client has no token, bad token or expired token : Response 401 with the error content :
TOKEN_EXPIRED : "La durée de validité de votre Token est dépassée, veuillez vous reconnecter."
TOKEN_INVALID : "Votre Token de connexion est invalide, veuillez vous reconnecter."
NO_TOKEN : "Aucun Token de connexion n'a été trouvé, veuillez vous connecter."
The Client has a good token :
No phone founds in the database : Response 404 with the error content : "No phone found in the database, please check your input parameters."
Phones found in the database : Response 200 with JSON array with phones in the Response content.
Diagrams
Physical model of data
Sequence diagram
Class diagram
To do
The input object type requires all informations to create a user. The role and the Client must be created by builder.
Goal
As an Client connected, I need to be able to collect my users list to the database.
Start
Client request to "/api/client/{client}/users", with :
{client} : their Client ID
Bearer token in the headers of the Request
Method : GET
Technical contraints
The Client must be connected and he must send the Bearer token to the headers of the Request
The Client can filtered the list with three parameters :
limit : number of user collects to the database
offset : the first user in the database
{client} (required) : the client ID
Scenarios
The Client has no token, bad token or expired token : Response 401 with the error content :
TOKEN_EXPIRED : "La durée de validité de votre Token est dépassée, veuillez vous reconnecter."
TOKEN_INVALID : "Votre Token de connexion est invalide, veuillez vous reconnecter."
NO_TOKEN : "Aucun Token de connexion n'a été trouvé, veuillez vous connecter."
The Client has a good token :
No user founds in the database : Response 404 with the error content : "No user found in the database, please check your input parameters."
Users found in the database : Response 200 with JSON array with users in the Response content.
Diagrams
Physical model of data
Sequence diagram
Class diagram
To do
Goal
As an Client connected, I need to be able to delete a user to the database.
Start
Client request to "/api/client/{client}/users/{id}", with :
{client} : their Client ID
{id} : the user ID
Bearer token in the headers of the Request
Method : DELETE
Technical contraints
The Client must be connected and he must send the Bearer token to the headers of the Request
The Client must have the user ID. He can collect this ID in the users list.
Scenarios
The Client has no token, bad token or expired token : Response 401 with the error content :
TOKEN_EXPIRED : "La durée de validité de votre Token est dépassée, veuillez vous reconnecter."
TOKEN_INVALID : "Votre Token de connexion est invalide, veuillez vous reconnecter."
NO_TOKEN : "Aucun Token de connexion n'a été trouvé, veuillez vous connecter."
The Client has a good token :
No user founds in the database : Response 404 with the error content : "No user found in the database, please check your input parameters."
User deleted in the database : Response 204
Diagrams
Physical model of data
Sequence diagram
Class diagram
To do
Goal
As an Client connected, I need to be able to collect a details of one user to the database.
Start
Client request to "/api/client/{client}/users", with :
{client} : their Client ID
Bearer token in the headers of the Request
Method : POST + datas of new user in the headers of the Request
Technical contraints
The Client must be connected and he must send the Bearer token to the headers of the Request
The Client must send the datas of the new user in JSON array :
{
"username" : " username" ,
"password" : " password"
}
Scenarios
The Client has no token, bad token or expired token : Response 401 with the error content :
TOKEN_EXPIRED : "La durée de validité de votre Token est dépassée, veuillez vous reconnecter."
TOKEN_INVALID : "Votre Token de connexion est invalide, veuillez vous reconnecter."
NO_TOKEN : "Aucun Token de connexion n'a été trouvé, veuillez vous connecter."
The Client has a good token :
A user with this username exists in the database : Response 409 with the error content : "A user with the same username exists. Please choose another username."
User created in the database : Response 201 with JSON array with new user in the Response content.
Diagrams
Physical model of data
Sequence diagram
Class diagram
To do
In URI it's the name that is used for the client identification. Refactoring the service so that be used client ID.