-
Notifications
You must be signed in to change notification settings - Fork 0
API
this API returns the following status codes:
| code | Description |
|---|---|
200 |
OK |
201 |
Created |
400 |
Bad Request |
401 |
Unauthorized |
403 |
Forbidden |
404 |
Not Found |
500 |
Internal Server Error |
for use the API you need to connect to the API with a user account.
url : https://api-perf-n-zen.vercel.app/api/V1/connect
For connect to the API you need to send a POST request with a JSON body like this :
POST /api/V1/connect?= HTTP/1.1
Content-Type: application/json
Host: localhost:3000
Content-Length: 59
{
"Mail_adress": "[email protected]",
"Password": "test"
}The API will return a JSON with the user information and the access token and the refresh token like this :
Response: 200
{
"newPerson": {
"ID_person": 1,
"First_name": "test",
"Last_name": "Test",
"Mail_adress": "[email protected]",
"Password": "test",
"ID_compagny": 1
},
"accessToken": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"refreshToken": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}url : https://api-perf-n-zen.vercel.app/api/V1/question
For use the question you need to send a GET request with the access token in the header like this :
GET /api/V1/question HTTP/1.1
Password: test
Content-Type: application/json
Authorization: Bearer eyJhbXXXXXXXXXXXX
Host: localhost:3000This request will return a JSON with the questionnaires like this :
Response: 200
[
{
"ID_question": 1,
"Title_question": "Comment estimez vous votre sommeil ?",
"ID_theme": 2
},
{
"ID_question": 2,
"Title_question": "Comment estimez vous votre humeur du jour ?",
"ID_theme": 1
},
{
"ID_question": 3,
"Title_question": "Comment estimez vous votre motivation à venir au travail ?",
"ID_theme": 3
}
]url : https://api-perf-n-zen.vercel.app/api/V1/question/:id
For use the question you need to send a GET request with the access token in the header like this :
GET /api/V1/question/1 HTTP/1.1
Password: test
Content-Type: application/json
Authorization: Bearer eyJhbGXXXXXXXXXX
Host: localhost:3000This request will return a JSON with the question and the questions like this :
Responce: 200
{
"ID_question": 1,
"Title_question": "Comment estimez vous votre sommeil ?",
"ID_theme": 2
}url : https://api-perf-n-zen.vercel.app/api/V1/question
For create a question you need to send a POST request with the access token in the header and a JSON body like this :
POST /api/V1/question/ HTTP/1.1
Password: test
Content-Type: application/json
Authorization: Bearer eyJhbGXXXXXXXXXXX
Host: localhost:3000
Content-Length: 57
{
"Question": "Comment allez vous ?",
"ID_theme": 2
}This request will return a JSON with the question like this :
Response: 201
{
"message": "La question Comment allez vous ? a été créée"
}If the question already exist the API will return a JSON with an error message like this :
Response: 409
{
"message": "La question Comment allez vous ? existe déjà"
}url : https://api-perf-n-zen.vercel.app/api/V1/question/:id
For update a question you need to send a PUT request with the access token in the header and a JSON body like this :
PUT /api/V1/question/1 HTTP/1.1
Password: test
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJJRF9wZXJzb24iOjEsIkZpcnN0X25hbWUiOiJEYW1pZW4iLCJMYXN0X25hbWUiOiJUZXN0IiwiTWFpbF9hZHJlc3MiOiJkYW1AdGVzdC5mciIsIlBhc3N3b3JkIjoidGVzdCIsIklEX2NvbXBhZ255IjoxLCJpYXQiOjE2ODg1ODU1NjQsImV4cCI6MTY4ODU4NzM2NH0.mxiGY0R_MZ47adV5lGCR1SRPOMYmxMj07ROd5F806xg
Host: localhost:3000
Content-Length: 61
{
"Question": "Comment allez vous ajd ?",
"ID_theme": 2
}This request will return a JSON with the question like this :
Response: 202
{
"message": "La question a été modifiée"
}If the question doesn't exist the API will return a JSON with an error message like this :
Response: 404
{
"message": "La question n'existe pas"
}url : https://api-perf-n-zen.vercel.app/api/V1/question/:id
For delete a question you need to send a DELETE request with the access token in the header like this :
DELETE /api/V1/question/4 HTTP/1.1
Password: test
Content-Type: application/json
Authorization: Bearer eyJhbGXXXXXXXXXXXXXX
Host: localhost:3000
Content-Length: 61
{
"Question": "Comment allez vous ajd ?",
"ID_theme": 2
}This request will return a JSON with the question like this :
Response: 202
{
"message": "La question a été supprimée"
}If the question doesn't exist the API will return a JSON with an error message like this :
Response: 404
{
"message": "La question n'existe pas"
}url : https://api-perf-n-zen.vercel.app/api/V1/theme
For use the theme you need to send a GET request with the access token in the header like this :
GET /api/V1/theme HTTP/1.1
Password: test
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJJRF9wZXJzb24iOjEsIkZpcnN0X25hbWUiOiJEYW1pZW4iLCJMYXN0X25hbWUiOiJUZXN0IiwiTWFpbF9hZHJlc3MiOiJkYW1AdGVzdC5mciIsIlBhc3N3b3JkIjoidGVzdCIsIklEX2NvbXBhZ255IjoxLCJpYXQiOjE2ODg1ODU1NjQsImV4cCI6MTY4ODU4NzM2NH0.mxiGY0R_MZ47adV5lGCR1SRPOMYmxMj07ROd5F806xg
Host: localhost:3000This request will return a JSON with the theme like this :
[
{
"ID_theme": 1,
"Theme_name": "humeur"
},
{
"ID_theme": 2,
"Theme_name": "sommeil"
},
{
"ID_theme": 3,
"Theme_name": "motivation"
}
]url : https://api-perf-n-zen.vercel.app/api/V1/theme/:id
For use the theme you need to send a GET request with the access token in the header like this :
GET /api/V1/theme/1 HTTP/1.1
Password: test
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJJRF9wZXJzb24iOjEsIkZpcnN0X25hbWUiOiJEYW1pZW4iLCJMYXN0X25hbWUiOiJUZXN0IiwiTWFpbF9hZHJlc3MiOiJkYW1AdGVzdC5mciIsIlBhc3N3b3JkIjoidGVzdCIsIklEX2NvbXBhZ255IjoxLCJpYXQiOjE2ODg1ODU1NjQsImV4cCI6MTY4ODU4NzM2NH0.mxiGY0R_MZ47adV5lGCR1SRPOMYmxMj07ROd5F806xg
Host: localhost:3000This request will return a JSON with the theme like this :
[
{
"ID_theme": 1,
"Theme_name": "humeur"
}
]If the theme doesn't exist the API will return a JSON with an error message like this :
Response: 404
{
"message": "Le thème n'existe pas"
}url : https://api-perf-n-zen.vercel.app/api/V1/theme
For create a theme you need to send a POST request with the access token in the header and a JSON body like this :
POST /api/V1/theme/ HTTP/1.1
Password: test
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJJRF9wZXJzb24iOjEsIkZpcnN0X25hbWUiOiJEYW1pZW4iLCJMYXN0X25hbWUiOiJUZXN0IiwiTWFpbF9hZHJlc3MiOiJkYW1AdGVzdC5mciIsIlBhc3N3b3JkIjoidGVzdCIsIklEX2NvbXBhZ255IjoxLCJpYXQiOjE2ODg1ODU1NjQsImV4cCI6MTY4ODU4NzM2NH0.mxiGY0R_MZ47adV5lGCR1SRPOMYmxMj07ROd5F806xg
Host: localhost:3000
Content-Length: 26
{
"Theme_name": "santé"
}This request will return a JSON with the theme like this :
Response: 201
{
"message": "Le thème a été créé"
}If the theme already exist the API will return a JSON with an error message like this :
Response: 409
{
"message": "Le thème existe déjà"
}url : https://api-perf-n-zen.vercel.app/api/V1/theme/:id
For update a theme you need to send a PUT request with the access token in the header and a JSON body like this :
PUT /api/V1/theme/1 HTTP/1.1
Password: test
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJJRF9wZXJzb24iOjEsIkZpcnN0X25hbWUiOiJEYW1pZW4iLCJMYXN0X25hbWUiOiJUZXN0IiwiTWFpbF9hZHJlc3MiOiJkYW1AdGVzdC5mciIsIlBhc3N3b3JkIjoidGVzdCIsIklEX2NvbXBhZ255IjoxLCJpYXQiOjE2ODg1ODgxODQsImV4cCI6MTY4ODU4OTk4NH0.tOEPL5d4PJnXXlhm6bYa1zFAgmrEIx520qCB9ArPCS4
Host: localhost:3000
Content-Length: 27
{
"Theme_name": "humeur"
}This request will return a JSON with the theme like this :
Response: 202
{
"message": "Le thème a été modifié"
}If the theme doesn't exist the API will return a JSON with an error message like this :
Response: 404
{
"message": "Le thème n'existe pas"
}url : https://api-perf-n-zen.vercel.app/api/V1/theme/:id
For delete a theme you need to send a DELETE request with the access token in the header like this :
DELETE /api/V1/theme/4 HTTP/1.1
Password: test
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJJRF9wZXJzb24iOjEsIkZpcnN0X25hbWUiOiJEYW1pZW4iLCJMYXN0X25hbWUiOiJUZXN0IiwiTWFpbF9hZHJlc3MiOiJkYW1AdGVzdC5mciIsIlBhc3N3b3JkIjoidGVzdCIsIklEX2NvbXBhZ255IjoxLCJpYXQiOjE2ODg1ODgxODQsImV4cCI6MTY4ODU4OTk4NH0.tOEPL5d4PJnXXlhm6bYa1zFAgmrEIx520qCB9ArPCS4
Host: localhost:3000This request will return a JSON with the theme like this :
Response: 202
{
"message": "Le thème a été supprimé"
}If the theme doesn't exist the API will return a JSON with an error message like this :
Response: 404
{
"message": "Le thème n'existe pas"
}url : https://api-perf-n-zen.vercel.app/api/V1/role
For get all roles you need to send a GET request with the access token in the header like this :
GET /api/V1/role HTTP/1.1
Password: test
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJJRF9wZXJzb24iOjEsIkZpcnN0X25hbWUiOiJEYW1pZW4iLCJMYXN0X25hbWUiOiJUZXN0IiwiTWFpbF9hZHJlc3MiOiJkYW1AdGVzdC5mciIsIlBhc3N3b3JkIjoidGVzdCIsIklEX2NvbXBhZ255IjoxLCJpYXQiOjE2ODg1ODgxODQsImV4cCI6MTY4ODU4OTk4NH0.tOEPL5d4PJnXXlhm6bYa1zFAgmrEIx520qCB9ArPCS4
Host: localhost:3000This request will return a JSON with all roles like this :
Response: 200
[
{
"ID_role": "ADM",
"Role_name": "administrateur",
"Acces": "777"
},
{
"ID_role": "USR",
"Role_name": "User",
"Acces": "744"
}
]url : https://api-perf-n-zen.vercel.app/api/V1/role/:id
For get a role by ID you need to send a GET request with the access token in the header like this :
GET /api/V1/role/ADM HTTP/1.1
Password: test
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJJRF9wZXJzb24iOjEsIkZpcnN0X25hbWUiOiJEYW1pZW4iLCJMYXN0X25hbWUiOiJUZXN0IiwiTWFpbF9hZHJlc3MiOiJkYW1AdGVzdC5mciIsIlBhc3N3b3JkIjoidGVzdCIsIklEX2NvbXBhZ255IjoxLCJpYXQiOjE2ODg1ODgxODQsImV4cCI6MTY4ODU4OTk4NH0.tOEPL5d4PJnXXlhm6bYa1zFAgmrEIx520qCB9ArPCS4
Host: localhost:3000