L'API est disponible depuis notre site avec la route /api
Auth /api/auth :
/register (POST) :
Ajoute un User à la BDD
Send:
{
"nickname": "A",
"email": "A@gmail.com",
"password": "test",
"password_confirmation": "test"
}
Success (201):
{
"data": {
"user": {
"id": 5,
"nickname": "A",
"email": "A@gmail.com",
"password": "test",
"updatedAt": "2019-06-24T11:20:47.099Z",
"createdAt": "2019-06-24T11:20:47.099Z"
}
},
"meta": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NSwibmlja25hbWUiOiJBIiwiZW1haWwiOiJBQGdtYWlsLmNvbSIsImlhdCI6MTU2MTM3NTI2OSwiZXhwIjoxNTYxNDYxNjY5fQ.YoC5PeA_FYDcbzC9oPA750jgGuU9qTQt-by9Ow1mzW8"
}
}
Error (400):
{
"err": "message d'éreur"
}
/login (POST) :
Trouve le User dans la BDD et le retourne
Send:
{
"nickname": "A",
"password": "test"
}
Success (201):
{
"data": {
"user": {
// user data
}
},
"meta": {
"token": // user token
}
}
Error (400):
{
"err": "message d'éreur"
}
User /api/user :
/show (GET) :
Retourne tous les Users de la BDD
Success (201):
{
"users": [
{
"id": 1,
"nickname": "A",
"email": "A@gmail.com",
"password": "test",
"createdAt": "2019-06-24T07:02:00.647Z",
"updatedAt": "2019-06-24T07:02:00.647Z"
},
{
"id": 2,
"nickname": "B",
"email": "B@gmail.com",
"password": "test",
"createdAt": "2019-06-24T08:04:52.256Z",
"updatedAt": "2019-06-24T08:04:52.256Z"
}
]
}
/changePassword (PUT) :
Change le mot de pass du User et le retourne
Send:
{
"id": 5,
"password": "test",
"newPassword": "test2",
"newPassword_confirmation": "test2"
}
Success (201):
{
"data": {
"user": {
// user data
}
},
"meta": {
"token": // user token
}
}
Error (400):
{
"err": "message d'éreur"
}
/delete (DELETE) :
supprime un User et le retourne
Send:
{
"id": 5
}
Success (201):
{
"data": {
"user": {
// user data
}
}
}
Error (400):
{
"err": "message d'éreur"
}
Type /api/type :
/show (GET) :
Retourne tous les Types de la BDD
Success (201):
{
"types": [
{
"id": 1,
"name": "test",
"createdAt": "2019-06-25T07:37:32.164Z",
"updatedAt": "2019-06-25T07:37:32.164Z"
},
{
"id": 2,
"name": "soap-alain",
"createdAt": "2019-06-26T21:49:51.272Z",
"updatedAt": "2019-06-26T21:49:51.272Z"
}
]
}
Error (400):
{
"err": "message d'éreur"
}
/create (POST) :
Ajoute un Type à la BDD
Send:
{
"name": "soap-alain"
}
Success (201):
{
"data": {
"type": {
"id": 2,
"name": "soap-alain",
"updatedAt": "2019-06-24T11:20:47.099Z",
"createdAt": "2019-06-24T11:20:47.099Z"
}
}
}
Error (400):
{
"err": "message d'éreur"
}
/delete (DELETE) :
supprime un Type et le retourne
Send:
{
"id": 2
}
Success (201):
{
"data": {
"type": {
// type data
}
}
}
Error (400):
{
"err": "message d'éreur"
}
product /api/product :
/show (GET) :
Retourne tous les Products de la BDD
Success (201):
{
"products": [
{
"id": 1,
"name": "water",
"barcode": 32682652,
"createdAt": "2019-06-25T07:44:17.255Z",
"updatedAt": "2019-06-25T07:44:17.255Z",
"TypeId": 1
}
]
}
Error (400):
{
"err": "message d'éreur"
}
/create (POST) :
Ajoute un Product à la BDD
Send:
{
"name": "water",
"barcode": 32682652,
"typeId": 1
}
Success (201):
{
"data": {
"product": {
"id": 1,
"name": "water",
"barcode": 32682652,
"createdAt": "2019-06-25T07:44:17.255Z",
"updatedAt": "2019-06-25T07:44:17.255Z",
"TypeId": 1
}
}
}
Error (400):
{
"err": "message d'éreur"
}
/delete (DELETE) :
supprime un Product et le retourne
Send:
{
"id": 1
}
Success (201):
{
"data": {
"product": {
// product data
}
}
}
Error (400):
{
"err": "message d'éreur"
}
consume /api/consume :
/show (GET) :
Retourne tous les consumes de la BDD
Success (201):
{
"products": [
{
"id": 1,
"longitude": 2.363148,
"latitude": 48.788703,
"createdAt": "2019-06-25T07:58:36.186Z",
"updatedAt": "2019-06-25T07:58:36.186Z",
"UserId": 5,
"ProductId": 1
}
]
}
Error (400):
{
"err": "message d'éreur"
}
/create (POST) :
Ajoute un Consume à la BDD
Send:
{
"longitude": 2.363148,
"latitude": 48.788703,
"UserId": 5,
"ProductId": 1
}
Success (201):
{
"data": {
"consume": {
"id": 1,
"longitude": 2.363148,
"latitude": 48.788703,
"createdAt": "2019-06-25T07:58:36.186Z",
"updatedAt": "2019-06-25T07:58:36.186Z",
"UserId": 5,
"ProductId": 1
}
}
}
Error (400):
{
"err": "message d'éreur"
}
/createRecursive (POST) :
Ajoute un Consume à la BDD
Send:
{
"longitude": 2.363148,
"latitude": 48.788703,
"productName": "testProduct",
"productBarCode": 12345,
"typeName": "testName",
"userId": 1
}
Success (201):
{
"data": {
"consume": {
"id": 1,
"longitude": 2.363148,
"latitude": 48.788703,
"UserId": 1,
"ProductId": 1,
"updatedAt": "2019-07-02T09:31:55.640Z",
"createdAt": "2019-07-02T09:31:55.640Z"
}
}
}
Error (400):
{
"err": "message d'éreur"
}
/delete (DELETE) :
supprime un Consume et le retourne
Send:
{
"id": 1
}
Success (201):
{
"data": {
"consume": {
// consume data
}
}
}
Error (400):
{
"err": "message d'éreur"
}
/getAll (GET) :
retourne tous les consumes de la BDD avec toutes les infos lier
Success (201):
{
"consumes": [
{
"id": 1,
"longitude": 2.363148,
"latitude": 48.788703,
"createdAt": "2019-06-25T07:58:36.186Z",
"updatedAt": "2019-06-25T07:58:36.186Z",
"UserId": 5,
"ProductId": 1,
"User": {
"id": 5,
"nickname": "A",
"email": "A@gmail.com",
"password": "test",
"createdAt": "2019-06-24T11:20:47.099Z",
"updatedAt": "2019-06-24T11:20:47.099Z"
},
"Product": {
"id": 1,
"name": "water",
"barcode": 32682652,
"createdAt": "2019-06-25T07:44:17.255Z",
"updatedAt": "2019-06-25T07:44:17.255Z",
"TypeId": 1,
"Type": {
"id": 1,
"name": "test",
"createdAt": "2019-06-25T07:37:32.164Z",
"updatedAt": "2019-06-25T07:37:32.164Z"
}
}
}
]
}
/getByUserId/:userId (GET) :
retourne tous les consumes de la BDD avec toutes les infos lier à un User
Success (201):
{
"consumes": [
{
"id": 1,
"key": "feyfg",
"title": "test",
"description": "testtesttest",
"longitude": 2.363148,
"latitude": 48.788703,
"createdAt": "2019-06-25T07:58:36.186Z",
"updatedAt": "2019-06-25T07:58:36.186Z",
"UserId": 5,
"ProductId": 1,
"User": {
"id": 5,
"nickname": "A",
"email": "A@gmail.com",
"password": "test",
"createdAt": "2019-06-24T11:20:47.099Z",
"updatedAt": "2019-06-24T11:20:47.099Z"
},
"Product": {
"id": 1,
"name": "water",
"barcode": 32682652,
"createdAt": "2019-06-25T07:44:17.255Z",
"updatedAt": "2019-06-25T07:44:17.255Z",
"TypeId": 1,
"Type": {
"id": 1,
"name": "test",
"createdAt": "2019-06-25T07:37:32.164Z",
"updatedAt": "2019-06-25T07:37:32.164Z"
}
}
}
]
}