Robert 2 API

General notes

This documentation is automatically generated with Postmanerator using a Postman collection that is located in the source code of the application, into utilities/postman/ folder.

Introduction

This is the complete documentation of Robert 2 private API.
This API exists to be used with a Robert 2 application client (GUI).

Overview

Please use you own environment variables. These variables are : robert2_url, robert2_email, and robert2_password.

In this documentation you’ll see that these variables are replaced by the following examples:

  • url: robert2-api.dev
  • email: your-email@dev.test
  • password: ******.

Of course, if you want to use the postman collection, you’ll have to replace those values in your own environment.

Authentication

Robert 2 API uses JWT Authentication.

At first, always ask for an Auth token by using the AUTH - Token request. In the response payload (if it’s succesful) there is a token which should be stored locally, in order to be inserted in all other future requests’ headers, as a Bearer token header.

Here is an example of Authorization header value:

Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE1NDYyMTc3OTksImV4cCI6MTU0NjIyNDk5OSwidXNl

In postman, this is done automatically by using a global variable auth_token, which is then used in each requests’ headers.

API detail

AUTH - Token

This is the only way to claim access to the API.

If the given username and password are provided, the response contains a token, which must then be included in every subsequent requests ‘ headers, for them to be authorized access.

POST /api/token/ HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json

{
    "identifier": "your-email@dev.test",
    "password": "******"
}
curl -X POST -H "Content-Type: application/json" -d '{
    "identifier": "your-email@dev.test",
    "password": "******"
}' "http://robert2-api.dev/api/token/"
Example: POST http://robert2-api.dev/api/token/
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}
Status 400 Bad Request
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": {
            "identifier": [
                "identifier must not be empty"
            ],
            "password": [
                "password must not be empty",
                "password must have a length greater than 4"
            ]
        }
    }
}
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}
Status 200 OK
Cache-Control private, no-cache
Content-Type application/json;charset=utf-8
{
    "user": {
        "id": 1,
        "pseudo": "admin",
        "email": "admin@robertmanager.org",
        "group_id": "admin",
        "created_at": "2018-12-26 23:05:53",
        "updated_at": "2018-12-26 23:05:53",
        "deleted_at": null,
        "person": {
            "id": 1,
            "user_id": 1,
            "first_name": "Admin",
            "last_name": "Example",
            "nickname": null,
            "email": null,
            "phone": null,
            "street": null,
            "postal_code": null,
            "locality": null,
            "country_id": null,
            "company_id": null,
            "note": null,
            "created_at": "2018-12-26 23:05:53",
            "updated_at": "2018-12-26 23:05:53",
            "deleted_at": null,
            "full_name": "Admin Example",
            "country": null
        }
    },
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE1NDYyMTY5OTMsImV4cCI6MTU0NjIyNDE5MywidXNlciI6eyJpZCI6MSwicHNldWRvIjoicG9sbyIsImVtYWlsIjoicG9sb0Bwb2xvc3Nvbi5jb20iLCJncm91cF9pZCI6ImFkbWluIiwiY3JlYXRlZF9hdCI6IjIwMTgtMTItMjYgMjM6MDU6NTMiLCJ1cGRhdGVkX2F0IjoiMjAxOC0xMi0yNiAyMzowNTo1MyIsImRlbGV0ZWRfYXQiOm51bGwsInBlcnNvbiI6eyJpZCI6MSwidXNlcl9pZCI6MSwiZmlyc3RfbmFtZSI6IlZdfERfLCJsYXN0X25hbWUiOiJNYWlsbGFyZGV0Iiwibmlja25hbWUiOm51bGwsImVtYWlsIjpudWxsLCJwaG9uZSI6bnVsbCwic3RyZWV0IjpudWxsLCJwb3N0YWxfY29kZSI6bnVsbCwibG9jYWxpdHkiOm51bGwsImNvdW50cnlfaWQiOm51bGwsImNvbXBhbnlfaWQiOm51bGwsIm5vdGUiOm51bGwsImNyZWF0ZWRfYXQiOiIyMDE4LTEyLTI2IDIzOjA1OjUzIiwidXBkYXRlZF9hdCI6IjIwMTgtMTItMjYgMjM6MDU6NTMiLCJkZWxldGVkX2F0IjpudWxsLCJmdWxsX25hbWUiOiJQb2xvIE1haWxsYXJkZFrgoMsjb3VudHJ5IjpudWxsfX19.aGlHpQSQ1ftQCd_F3Uq7CtikC-trfs4l0j7xskaLOyU"
}

Bills

Bills are attached to events, beneficiaries and contain materials. You can create bills (with a discount rate) and delete them, it’s not possible to update them. When a bill is created, a PDF file is generated within the /data/bills folder.

The number of a bill is composed by the current date (format Ymd) and the id of the attached event.

Create bill

Create a bill for a given event. This also creates a PDF file, and removes any existing bill for the event.

POST /api/events/1/bill HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json

{
    "discountRate": 10.0
}
curl -X POST -H "Content-Type: application/json" -d '{
    "discountRate": 10.0
}
' "http://robert2-api.dev/api/events/1/bill"
Example: POST http://robert2-api.dev/api/events/1/bill
Status 201 Created
Content-Type application/json
{
    "id": 8,
    "number": "20200212-00001",
    "date": "2020-02-12 10:45:46",
    "event_id": 1,
    "beneficiary_id": 2,
    "materials": [
        {
            "id": 20,
            "name": "Panel LED IP",
            "reference": "Panel IP",
            "park_id": 1,
            "category_id": 2,
            "sub_category_id": null,
            "rental_price": 15,
            "replacement_price": 950,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "quantity": 1
        },
        {
            "id": 209,
            "name": "Amplifié L-Acoustics MTD 108P",
            "reference": "MTD108P",
            "park_id": 11,
            "category_id": 1,
            "sub_category_id": 2,
            "rental_price": 37,
            "replacement_price": 3000,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "quantity": 2
        },
        {
            "id": 242,
            "name": "1 16Amono male vers1 pc 16A femelle",
            "reference": "adaptri camping 16mono-PC16",
            "park_id": 1,
            "category_id": 2,
            "sub_category_id": null,
            "rental_price": 1,
            "replacement_price": 30,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "quantity": 2
        }
    ],
    "degressive_rate": 1.75,
    "discount_rate": 10,
    "vat_rate": 20,
    "due_amount": 171.99,
    "replacement_amount": 7010,
    "currency": "EUR",
    "user_id": 1,
    "updated_at": "2020-02-12 10:45:46",
    "created_at": "2020-02-12 10:45:46"
}

Get one bill

Retreive one bill data.

GET /api/bills/1 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X GET -H "Content-Type: application/json" "http://robert2-api.dev/api/bills/1"
Example: GET http://robert2-api.dev/api/bills/1
Status 404 Not Found
Content-Type application/json
{
    "success": false,
    "error": {
        "requested": "(GET) http://robert2-api.etoilenoire/api/bills/1",
        "code": 404,
        "message": "The required resource was not found.",
        "file": "/home/polo/WEB/perso/Robert/Robert2-api/src/App/Controllers/BillController.php, line 40."
    }
}
Status 200 OK
Content-Type application/json
{
    "id": 8,
    "number": "20200212-00001",
    "date": "2020-02-12 10:45:46",
    "event_id": 1,
    "beneficiary_id": 2,
    "materials": [
        {
            "id": 20,
            "name": "Panel LED IP",
            "reference": "Panel IP",
            "park_id": 1,
            "category_id": 2,
            "sub_category_id": null,
            "rental_price": 15,
            "replacement_price": 950,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "quantity": 1
        },
        {
            "id": 209,
            "name": "Amplifié L-Acoustics MTD 108P",
            "reference": "MTD108P",
            "park_id": 11,
            "category_id": 1,
            "sub_category_id": 2,
            "rental_price": 37,
            "replacement_price": 3000,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "quantity": 2
        },
        {
            "id": 242,
            "name": "1 16Amono male vers1 pc 16A femelle",
            "reference": "adaptri camping 16mono-PC16",
            "park_id": 1,
            "category_id": 2,
            "sub_category_id": null,
            "rental_price": 1,
            "replacement_price": 30,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "quantity": 2
        }
    ],
    "degressive_rate": 1.75,
    "discount_rate": 10,
    "vat_rate": 20,
    "due_amount": 171.99,
    "replacement_amount": 7010,
    "currency": "EUR",
    "user_id": 1,
    "updated_at": "2020-02-12 10:45:46",
    "created_at": "2020-02-12 10:45:46"
}

Delete a bill

Remove a bill using its ID.

Works in 2 steps:

  • First call to this request: sets the deleted_at field with current date and time.
  • Second call: actually delete the item from database.
DELETE /api/bills/1 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X DELETE -H "Content-Type: application/json" "http://robert2-api.dev/api/bills/1"
Example: DELETE http://robert2-api.dev/api/bills/1
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "destroyed": true
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 8,
    "number": "20200212-00001",
    "date": "2020-02-12 10:45:46",
    "event_id": 1,
    "beneficiary_id": 2,
    "materials": [
        {
            "id": 20,
            "name": "Panel LED IP",
            "reference": "Panel IP",
            "park_id": 1,
            "category_id": 2,
            "sub_category_id": null,
            "rental_price": 15,
            "replacement_price": 950,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "quantity": 1
        },
        {
            "id": 209,
            "name": "Amplifié L-Acoustics MTD 108P",
            "reference": "MTD108P",
            "park_id": 11,
            "category_id": 1,
            "sub_category_id": 2,
            "rental_price": 37,
            "replacement_price": 3000,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "quantity": 2
        },
        {
            "id": 242,
            "name": "1 16Amono male vers1 pc 16A femelle",
            "reference": "adaptri camping 16mono-PC16",
            "park_id": 1,
            "category_id": 2,
            "sub_category_id": null,
            "rental_price": 1,
            "replacement_price": 30,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "quantity": 2
        }
    ],
    "degressive_rate": 1.75,
    "discount_rate": 10,
    "vat_rate": 20,
    "due_amount": 171.99,
    "replacement_amount": 7010,
    "currency": "EUR",
    "user_id": 1,
    "updated_at": "2020-02-12 10:45:46",
    "created_at": "2020-02-12 10:45:46",
    "deleted_at": null
}
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}

Categories

Categories are simple entities that allows to tidy up materials. Each category may have several sub-categories.

Create category

Just give a name, and here you go.

POST /api/categories HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json

{
    "name": "newCateg"
}
curl -X POST -H "Content-Type: application/json" -d '{
    "name": "newCateg"
}
' "http://robert2-api.dev/api/categories"
Example: POST http://robert2-api.dev/api/categories
Status 401 Unauthorized
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "Signature verification failed",
        "details": null
    }
}
Status 401 Unauthorized
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "Expired token",
        "details": null
    }
}
Status 401 Unauthorized
Content-Type application/json;charset=utf-8
{
    "error": "Unauthorized by ACL: users of group 'visitor' are not allowed to access this API endpoint."
}
Status 201 Created
Content-Type application/json;charset=utf-8
{
    "id": 5,
    "name": "radio",
    "updated_at": "2018-12-31 13:14:19",
    "created_at": "2018-12-31 13:14:19",
    "sub_categories": []
}
Status 400 Bad Request
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": {
            "name": [
                "name must have a length between 2 and 96"
            ]
        }
    }
}

Update category

Change the name of a category.

PUT /api/categories/3 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json

{
    "name": null
}
curl -X PUT -H "Content-Type: application/json" -d '{
    "name": null
}
' "http://robert2-api.dev/api/categories/3"
Example: PUT http://robert2-api.dev/api/categories/3
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 5,
    "name": "Just modified",
    "created_at": "2018-12-31 13:14:19",
    "updated_at": "2018-12-31 13:17:24",
    "deleted_at": null,
    "sub_categories": []
}
Status 400 Bad Request
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": {
            "name": [
                "name must have a length between 2 and 96"
            ]
        }
    }
}
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}
Status 401 Unauthorized
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "Token not found.",
        "details": null
    }
}

Get all categories

Retreive all the categories of the application, with their nested sub-categories, sorted by name, and within pagination.

GET /api/categories HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
x-api-key: Bearer {{auth_token}}
curl -X GET -H "Content-Type: application/json" -H "x-api-key: Bearer {{auth_token}}" "http://robert2-api.dev/api/categories"
Example: GET http://robert2-api.dev/api/categories
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "pagination": {
        "current_page": 1,
        "first_page_url": "/api/categories?page=1",
        "from": 1,
        "last_page": 1,
        "last_page_url": "/api/categories?page=1",
        "next_page_url": null,
        "path": "/api/categories",
        "per_page": 100,
        "prev_page_url": null,
        "to": 5,
        "total": 5
    },
    "data": [
        {
            "id": 1,
            "name": "sound",
            "created_at": "2018-12-26 23:06:09",
            "updated_at": "2018-12-26 23:06:09",
            "deleted_at": null,
            "sub_categories": [
                {
                    "id": 1,
                    "name": "Mix",
                    "category_id": 1
                }
            ]
        },
        {
            "id": 2,
            "name": "light",
            "created_at": "2018-12-29 19:15:20",
            "updated_at": "2018-12-29 19:15:20",
            "deleted_at": null,
            "sub_categories": []
        }
    ]
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "pagination": {
        "current_page": 1,
        "first_page_url": "/api/categories?deleted=1&page=1",
        "from": 1,
        "last_page": 1,
        "last_page_url": "/api/categories?deleted=1&page=1",
        "next_page_url": null,
        "path": "/api/categories",
        "per_page": 100,
        "prev_page_url": null,
        "to": 2,
        "total": 2
    },
    "data": [
        {
            "id": 5,
            "name": "deleted",
            "created_at": "2019-01-06 18:59:39",
            "updated_at": "2019-01-13 11:43:02",
            "deleted_at": "2019-01-13 11:43:02",
            "sub_categories": []
        },
        {
            "id": 4,
            "name": "other one",
            "created_at": "2019-01-06 18:59:39",
            "updated_at": "2019-01-13 11:42:50",
            "deleted_at": "2019-01-13 11:42:50",
            "sub_categories": []
        }
    ]
}

Get one category

Retreive one category with its nested sub-categories

GET /api/categories/1 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X GET -H "Content-Type: application/json" "http://robert2-api.dev/api/categories/1"
Example: GET http://robert2-api.dev/api/categories/1
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 1,
    "name": "sound",
    "created_at": "2018-12-26 23:06:09",
    "updated_at": "2018-12-26 23:06:09",
    "deleted_at": null,
    "sub_categories": [
        {
            "id": 1,
            "name": "Mix",
            "category_id": 1
        }
    ]
}

Delete a category

Remove a category using its ID.

Works in 2 steps:

  • First call to this request: sets the deleted_at field with current date and time.
  • Second call: actually delete the item from database.
DELETE /api/categories/5 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X DELETE -H "Content-Type: application/json" "http://robert2-api.dev/api/categories/5"
Example: DELETE http://robert2-api.dev/api/categories/5
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "destroyed": true
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 5,
    "name": "Just modified",
    "created_at": "2018-12-31 13:14:19",
    "updated_at": "2018-12-31 13:25:22",
    "deleted_at": "2018-12-31 13:25:22",
    "sub_categories": []
}

Restore a category

Restore a category that was previously soft-deleted.

PUT /api/categories/restore/5 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X PUT -H "Content-Type: application/json" "http://robert2-api.dev/api/categories/restore/5"
Example: PUT http://robert2-api.dev/api/categories/restore/5
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 5,
    "name": "divers",
    "created_at": "2019-01-06 18:59:39",
    "updated_at": "2019-01-13 16:33:35",
    "deleted_at": null,
    "sub_categories": []
}

Sub Categories

Categories are simple entities that allows to tidy up materials. Each category may have several sub-categories.

Create sub-category

Just give a name and a valid category ID, and here you go.

POST /api/subcategories HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json

{
    "name": "speakers",
    "category_id": 1
}
curl -X POST -H "Content-Type: application/json" -d '{
    "name": "speakers",
    "category_id": 1
}
' "http://robert2-api.dev/api/subcategories"
Example: POST http://robert2-api.dev/api/subcategories
Status 400 Bad Request
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "code": 400,
        "message": "Validation failed. See error[details] for more informations.",
        "details": {
            "category_id": [
                "category_id must not be empty",
                "category_id must be numeric"
            ]
        }
    }
}
Status 201 Created
Content-Type application/json;charset=utf-8
{
    "name": "speakers",
    "category_id": 1,
    "updated_at": "2019-02-02 15:43:13",
    "created_at": "2019-02-02 15:43:13",
    "id": 2
}

Update sub-category

Change the name of a sub-category.

PUT /api/subcategories/1 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json

{
    "name": "Mixers modified"
}
curl -X PUT -H "Content-Type: application/json" -d '{
    "name": "Mixers modified"
}
' "http://robert2-api.dev/api/subcategories/1"
Example: PUT http://robert2-api.dev/api/subcategories/1
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 1,
    "name": "Mixers modified",
    "category_id": 1,
    "created_at": "2019-02-02 15:37:56",
    "updated_at": "2019-02-02 15:50:52",
    "deleted_at": null
}
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "requested": "(PUT) http://robert2-api.nostromo/api/subcategories/999",
        "code": 404,
        "message": "The required resource was not found.",
        "file": "/home/polo/WEB/perso/Robert2-api/src/App/Controllers/BaseController.php, line 105."
    }
}

Delete a sub-category

Remove a sub-category using its ID.

Works in 2 steps:

  • First call to this request: sets the deleted_at field with current date and time.
  • Second call: actually delete the item from database.
DELETE /api/subcategories/2 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X DELETE -H "Content-Type: application/json" "http://robert2-api.dev/api/subcategories/2"
Example: DELETE http://robert2-api.dev/api/subcategories/2
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 2,
    "name": "speakers",
    "category_id": 1,
    "created_at": "2019-02-02 15:43:13",
    "updated_at": "2019-02-02 15:43:23",
    "deleted_at": "2019-02-02 15:43:23"
}
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "requested": "(DELETE) http://robert2-api.nostromo/api/subcategories/999",
        "code": 404,
        "message": "The required resource was not found.",
        "file": "/home/polo/WEB/perso/Robert2-api/src/App/Models/BaseModel.php, line 118."
    }
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "destroyed": true
}

Restore a sub-category

Restore a sub-category that was previously soft-deleted.

PUT /api/subcategories/restore/2 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X PUT -H "Content-Type: application/json" "http://robert2-api.dev/api/subcategories/restore/2"
Example: PUT http://robert2-api.dev/api/subcategories/restore/2
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 2,
    "name": "speakers",
    "category_id": 1,
    "created_at": "2019-02-02 15:43:13",
    "updated_at": "2019-02-02 15:46:35",
    "deleted_at": null
}
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "requested": "(PUT) http://robert2-api.nostromo/api/subcategories/restore/999",
        "code": 404,
        "message": "The required resource was not found.",
        "file": "/home/polo/WEB/perso/Robert2-api/src/App/Models/BaseModel.php, line 143."
    }
}

Companies

Companies have a name, and a set of other useful informations like address and phone number. They can be linked to Persons.

Create company

Give at least the company legal name, and voilà!

POST /api/companies HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json

{
	"legal_name": "Gniuk Company"
}
curl -X POST -H "Content-Type: application/json" -d '{
	"legal_name": "Gniuk Company"
}' "http://robert2-api.dev/api/companies"
Example: POST http://robert2-api.dev/api/companies
Status 201 Created
Content-Type application/json;charset=utf-8
{
    "id": 1,
    "legal_name": "New Company",
    "updated_at": "2018-12-31 15:04:18",
    "created_at": "2018-12-31 15:04:18",
    "country": null
}
Status 400 Bad Request
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": {
            "legal_name": [
                "legal_name must not be empty",
                "legal_name must have a length between 1 and 255"
            ],
            "postal_code": [
                "postal_code must have a length lower than 10"
            ],
            "country_id": [
                "country_id must be numeric"
            ],
            "phone": [
                "phone must be a valid telephone number"
            ]
        }
    }
}

Update company

Modify a company’s informations.

PUT /api/companies/3 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json

{
	"legal_name": "Modified Company",
	"street": "central av. 42",
	"postal_code": "5550",
	"locality": "Somewhereville",
	"country_id": 1
}
curl -X PUT -H "Content-Type: application/json" -d '{
	"legal_name": "Modified Company",
	"street": "central av. 42",
	"postal_code": "5550",
	"locality": "Somewhereville",
	"country_id": 1
}' "http://robert2-api.dev/api/companies/3"
Example: PUT http://robert2-api.dev/api/companies/3
Status 400 Bad Request
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": {
            "country_id": [
                "country_id must be numeric"
            ]
        }
    }
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 1,
    "legal_name": "Modified Company",
    "street": "central av. 42",
    "postal_code": "5550",
    "locality": "Somewhereville",
    "country_id": 1,
    "phone": null,
    "note": null,
    "created_at": "2018-12-31 15:04:18",
    "updated_at": "2018-12-31 15:14:15",
    "deleted_at": null,
    "country": {
        "id": 1,
        "name": "France",
        "code": "FR"
    }
}
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}

Get all companies

Retreive all the companies in the application, sorted by name, and within pagination.

GET /api/companies HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X GET -H "Content-Type: application/json" "http://robert2-api.dev/api/companies"
Example: GET http://robert2-api.dev/api/companies
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "pagination": {
        "current_page": 1,
        "first_page_url": "/api/companies?deleted=1&page=1",
        "from": 1,
        "last_page": 1,
        "last_page_url": "/api/companies?deleted=1&page=1",
        "next_page_url": null,
        "path": "/api/companies",
        "per_page": 100,
        "prev_page_url": null,
        "to": 3,
        "total": 3
    },
    "data": [
        {
            "id": 6,
            "legal_name": "Gniuk Company",
            "street": null,
            "postal_code": null,
            "locality": null,
            "country_id": null,
            "phone": null,
            "note": null,
            "created_at": "2019-01-12 00:02:01",
            "updated_at": "2019-01-12 00:03:34",
            "deleted_at": "2019-01-12 00:03:34",
            "country": null
        },
        {
            "id": 4,
            "legal_name": "Nouche Company",
            "street": null,
            "postal_code": null,
            "locality": null,
            "country_id": null,
            "phone": null,
            "note": null,
            "created_at": "2019-01-10 22:44:04",
            "updated_at": "2019-01-10 22:44:33",
            "deleted_at": "2019-01-10 22:44:33",
            "country": null
        },
        {
            "id": 3,
            "legal_name": "Zer Company",
            "street": null,
            "postal_code": null,
            "locality": null,
            "country_id": null,
            "phone": null,
            "note": null,
            "created_at": "2019-01-10 22:43:58",
            "updated_at": "2019-01-12 00:01:10",
            "deleted_at": "2019-01-12 00:01:10",
            "country": null
        }
    ]
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "pagination": {
        "current_page": 1,
        "first_page_url": "/api/companies?page=1",
        "from": 1,
        "last_page": 1,
        "last_page_url": "/api/companies?page=1",
        "next_page_url": null,
        "path": "/api/companies",
        "per_page": 100,
        "prev_page_url": null,
        "to": 1,
        "total": 1
    },
    "data": [
        {
            "id": 3,
            "legal_name": "Modified Company",
            "street": "central av. 42",
            "postal_code": "5550",
            "locality": "Somewhereville",
            "country_id": 1,
            "phone": null,
            "note": null,
            "created_at": "2018-12-31 15:04:18",
            "updated_at": "2018-12-31 15:14:15",
            "deleted_at": null,
            "country": {
                "id": 1,
                "name": "France",
                "code": "FR"
            }
        }
    ]
}

Get one company

Retreive one company with all its informations.

GET /api/companies/1 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X GET -H "Content-Type: application/json" "http://robert2-api.dev/api/companies/1"
Example: GET http://robert2-api.dev/api/companies/1
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 1,
    "legal_name": "Wonderful inc.",
    "street": "central av. 42",
    "postal_code": "5550",
    "locality": "Somewhereville",
    "country_id": 1,
    "phone": null,
    "note": null,
    "created_at": "2018-12-31 15:04:18",
    "updated_at": "2018-12-31 15:14:15",
    "deleted_at": null,
    "country": {
        "id": 1,
        "name": "France",
        "code": "FR"
    }
}
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}

Get a company's people

Retreive all the Persons attached to a given company.

GET /api/companies/1/persons HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X GET -H "Content-Type: application/json" "http://robert2-api.dev/api/companies/1/persons"
Example: GET http://robert2-api.dev/api/companies/1/persons
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "pagination": {
        "current_page": 1,
        "first_page_url": "/api/companies/3/persons?page=1",
        "from": 1,
        "last_page": 1,
        "last_page_url": "/api/companies/3/persons?page=1",
        "next_page_url": null,
        "path": "/api/companies/3/persons",
        "per_page": 100,
        "prev_page_url": null,
        "to": 1,
        "total": 1
    },
    "data": [
        {
            "id": 3,
            "user_id": null,
            "first_name": "Jean",
            "last_name": "Destroy",
            "nickname": "to-be-deleted",
            "email": null,
            "phone": null,
            "street": null,
            "postal_code": null,
            "locality": null,
            "country_id": null,
            "company_id": 3,
            "note": null,
            "created_at": "2018-12-31 00:52:53",
            "updated_at": "2018-12-31 00:52:53",
            "deleted_at": null,
            "full_name": "Destroy Jean",
            "country": null
        }
    ]
}

Search in companies

Search a company by its legal name.

GET /api/companies/search?legal_name=modif HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X GET -H "Content-Type: application/json" "http://robert2-api.dev/api/companies/search?legal_name=modif"
Example: GET http://robert2-api.dev/api/companies/search?legal_name=modif
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "pagination": {
        "current_page": 1,
        "first_page_url": "/api/companies/search?legal_name=modif&page=1",
        "from": 1,
        "last_page": 1,
        "last_page_url": "/api/companies/search?legal_name=modif&page=1",
        "next_page_url": null,
        "path": "/api/companies/search",
        "per_page": 100,
        "prev_page_url": null,
        "to": 1,
        "total": 1
    },
    "data": [
        {
            "id": 3,
            "legal_name": "Modified Company",
            "street": "central av. 42",
            "postal_code": "5550",
            "locality": "Somewhereville",
            "country_id": 1,
            "phone": null,
            "note": null,
            "created_at": "2018-12-31 15:04:18",
            "updated_at": "2018-12-31 15:14:15",
            "deleted_at": null,
            "country": {
                "id": 1,
                "name": "France",
                "code": "FR"
            }
        }
    ]
}

Delete a company

Remove a company using its ID.

Works in 2 steps:

  • First call to this request: sets the deleted_at field with current date and time.
  • Second call: actually delete the item from database.
DELETE /api/companies/1 HTTP/1.1
Host: robert2-api.dev
curl -X DELETE "http://robert2-api.dev/api/companies/1"
Example: DELETE http://robert2-api.dev/api/companies/1
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 1,
    "legal_name": "Modified Company",
    "street": "central av. 42",
    "postal_code": "5550",
    "locality": "Somewhereville",
    "country_id": 1,
    "phone": null,
    "note": null,
    "created_at": "2018-12-31 15:04:18",
    "updated_at": "2018-12-31 15:28:27",
    "deleted_at": "2018-12-31 15:28:27",
    "country": {
        "id": 1,
        "name": "France",
        "code": "FR"
    }
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "destroyed": true
}

Restore company

Restore a company that was previously soft-deleted.

PUT /api/companies/restore/1 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X PUT -H "Content-Type: application/json" "http://robert2-api.dev/api/companies/restore/1"
Example: PUT http://robert2-api.dev/api/companies/restore/1
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 1,
    "legal_name": "Modified Company",
    "street": "central av. 42",
    "postal_code": "5550",
    "locality": "Somewhereville",
    "country_id": 1,
    "phone": null,
    "note": null,
    "created_at": "2018-12-31 15:04:18",
    "updated_at": "2018-12-31 15:28:27",
    "deleted_at": null,
    "country": {
        "id": 1,
        "name": "France",
        "code": "FR"
    }
}

Events

Events are the main entity of the application. An event is defined by a title, a start date and an end date. An event can contain several Materials, as well as people: Assignees are the workers, and Beneficiaries are the clients (both refer to the ‘Person’ entity).

Create event

To create an event, the following fields must be provided:

  • user_id
  • title
  • start_date
  • end_date
  • location
POST /api/events HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json

{
	"user_id": 1,
    "title": "Fête de la musique",
    "start_date": "2019-06-21 00:00:00",
    "end_date": "2019-06-21 23:59:59",
    "is_confirmed": true,
    "location": "Toulouse - Place du Capitole",
    "beneficiaries": [5],
    "assignees": [3],
    "materials": [
    	{"id": 3, "quantity": 1},
    	{"id": 4, "quantity": 5}
    ]
}
curl -X POST -H "Content-Type: application/json" -d '{
	"user_id": 1,
    "title": "Fête de la musique",
    "start_date": "2019-06-21 00:00:00",
    "end_date": "2019-06-21 23:59:59",
    "is_confirmed": true,
    "location": "Toulouse - Place du Capitole",
    "beneficiaries": [5],
    "assignees": [3],
    "materials": [
    	{"id": 3, "quantity": 1},
    	{"id": 4, "quantity": 5}
    ]
}' "http://robert2-api.dev/api/events"
Example: POST http://robert2-api.dev/api/events
Status 201 Created
Content-Type application/json;charset=utf-8
{
    "user_id": 1,
    "title": "Nouvel an",
    "start_date": "2018-12-31 00:00:00",
    "end_date": "2019-01-01 23:59:59",
    "is_confirmed": true,
    "location": "Marseille",
    "updated_at": "2018-12-31 16:22:00",
    "created_at": "2018-12-31 16:22:00",
    "id": 2,
    "user": {
        "id": 1,
        "pseudo": "admin",
        "email": "admin@robertmanager.org",
        "group_id": "admin",
        "created_at": "2018-12-29 19:12:01",
        "updated_at": "2018-12-29 19:12:01",
        "deleted_at": null,
        "person": {
            "id": 2,
            "user_id": 2,
            "first_name": "Admin",
            "last_name": "Robertus",
            "nickname": null,
            "email": null,
            "phone": null,
            "street": null,
            "postal_code": null,
            "locality": null,
            "country_id": null,
            "company_id": null,
            "note": null,
            "created_at": "2018-12-29 19:12:01",
            "updated_at": "2018-12-29 19:12:01",
            "deleted_at": null,
            "full_name": "Robertus Admin",
            "country": null
        }
    },
    "beneficiaries": [],
    "assignees": [],
    "materials": []
}
Status 201 Created
Content-Type application/json
{
    "id": 3,
    "user_id": 1,
    "title": "Fête de la musique",
    "description": null,
    "start_date": "2019-06-21 00:00:00",
    "end_date": "2019-06-21 23:59:59",
    "is_confirmed": true,
    "location": "Toulouse - Place du Capitole",
    "created_at": "2019-09-21 14:25:52",
    "updated_at": "2019-09-21 14:25:52",
    "deleted_at": null,
    "user": {
        "id": 1,
        "pseudo": "admin",
        "email": "admin@robertmanager.org",
        "group_id": "admin",
        "created_at": "2018-12-29 19:12:01",
        "updated_at": "2018-12-29 19:12:01",
        "deleted_at": null,
        "person": {
            "id": 2,
            "user_id": 2,
            "first_name": "Admin",
            "last_name": "Robertus",
            "nickname": null,
            "email": null,
            "phone": null,
            "street": null,
            "postal_code": null,
            "locality": null,
            "country_id": null,
            "company_id": null,
            "note": null,
            "created_at": "2018-12-29 19:12:01",
            "updated_at": "2018-12-29 19:12:01",
            "deleted_at": null,
            "full_name": "Robertus Admin",
            "country": null
        }
    },
    "assignees": [
        {
            "id": 2,
            "first_name": "Member",
            "last_name": "Technician",
            "nickname": null,
            "full_name": "Technician Member",
            "country": null,
            "pivot": {
                "event_id": "3",
                "person_id": "2"
            }
        }
    ],
    "beneficiaries": [
        {
            "id": 3,
            "first_name": "Customer",
            "last_name": "Client",
            "full_name": "Client Customer",
            "country": null,
            "pivot": {
                "event_id": "3",
                "person_id": "3"
            }
        }
    ],
    "materials": [
        {
            "id": 3,
            "name": "Yamaha M7CL",
            "description": "La grosse berta new age",
            "reference": "M7CL",
            "park_id": 1,
            "category_id": 1,
            "sub_category_id": 1,
            "rental_price": 75.55,
            "stock_quantity": 5,
            "out_of_order_quantity": null,
            "replacement_price": 525.35,
            "serial_number": null,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "park": {
                "id": 1,
                "name": "default"
            },
            "category": {
                "id": 1,
                "name": "Son"
            },
            "sub_category": {
                "id": 1,
                "name": "Consoles de mix",
                "category_id": 1
            },
            "attributes": [],
            "pivot": {
                "event_id": 3,
                "material_id": 3,
                "quantity": 1
            }
        },
        {
            "id": 4,
            "name": "Projo PAR56",
            "description": "Petit spot tranquille",
            "reference": "PAR56",
            "park_id": 1,
            "category_id": 2,
            "sub_category_id": 4,
            "rental_price": 6.5,
            "stock_quantity": 24,
            "out_of_order_quantity": null,
            "replacement_price": null,
            "serial_number": null,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "park": {
                "id": 1,
                "name": "default"
            },
            "category": {
                "id": 2,
                "name": "Lumière"
            },
            "sub_category": {
                "id": 4,
                "name": "Projos Trad",
                "category_id": 2
            },
            "attributes": [],
            "pivot": {
                "event_id": 3,
                "material_id": 4,
                "quantity": 5
            }
        }
    ]
}
Status 400 Bad Request
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": {
            "title": [
                "title must have a length between 2 and 255"
            ],
            "start_date": [
                "start_date must be a valid date"
            ],
            "end_date": [
                "end_date must be a valid date"
            ],
            "is_confirmed": [
                "is_confirmed must be a boolean"
            ],
            "location": [
                "location must have a length between 2 and 64"
            ]
        }
    }
}

Update event

Modify an event informations.

PUT /api/events/1 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json

{
    "user_id": 2,
    "title": "C'est noël",
    "start_date": "2018-12-24 00:00:00",
    "end_date": "2018-12-25 23:59:59",
    "is_confirmed": true,
    "location": "Dijon, France",
    "beneficiaries": [23, 24],
    "assignees": [30, 31],
    "materials": [
    	{"id": 3, "quantity": 1},
    	{"id": 5, "quantity": 1},
    	{"id": 7, "quantity": 3}
    ]
}
curl -X PUT -H "Content-Type: application/json" -d '{
    "user_id": 2,
    "title": "C'est noël",
    "start_date": "2018-12-24 00:00:00",
    "end_date": "2018-12-25 23:59:59",
    "is_confirmed": true,
    "location": "Dijon, France",
    "beneficiaries": [23, 24],
    "assignees": [30, 31],
    "materials": [
    	{"id": 3, "quantity": 1},
    	{"id": 5, "quantity": 1},
    	{"id": 7, "quantity": 3}
    ]
}' "http://robert2-api.dev/api/events/1"
Example: PUT http://robert2-api.dev/api/events/1
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}
Status 400 Bad Request
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": {
            "user_id": [
                "user_id must be numeric"
            ],
            "title": [
                "title must have a length between 2 and 255"
            ],
            "start_date": [
                "start_date must be a valid date"
            ],
            "end_date": [
                "end_date must be a valid date"
            ],
            "is_confirmed": [
                "is_confirmed must be a boolean"
            ],
            "location": [
                "location must have a length between 2 and 64"
            ]
        }
    }
}
Status 200 OK
Content-Type application/json
{
    "id": 1,
    "user_id": 1,
    "title": "C'est noël",
    "description": "Petit test",
    "start_date": "2018-12-24 00:00:00",
    "end_date": "2018-12-25 23:59:59",
    "is_confirmed": true,
    "location": "Dijon, France",
    "created_at": "2019-01-13 11:45:14",
    "updated_at": "2019-09-20 00:00:55",
    "deleted_at": null,
    "user": {
        "id": 2,
        "pseudo": "newuser",
        "email": "newuser@robertmanager.org",
        "group_id": "member",
        "person": {
            "id": 3,
            "user_id": 2,
            "first_name": "Member",
            "last_name": "Test",
            "nickname": null,
            "email": null,
            "phone": null,
            "street": null,
            "postal_code": null,
            "locality": null,
            "country_id": null,
            "company_id": null,
            "note": null,
            "created_at": "2019-01-13 12:15:01",
            "updated_at": "2019-01-13 12:15:01",
            "deleted_at": null,
            "full_name": "Test Member",
            "country": null
        }
    },
    "assignees": [
        {
            "id": 5,
            "first_name": "Victor",
            "last_name": "Testing",
            "nickname": "Vic",
            "full_name": "Maillardet Victor",
            "country": null,
            "pivot": {
                "event_id": "1",
                "person_id": "5"
            }
        },
        {
            "id": 6,
            "first_name": "Emile",
            "last_name": "Loustik",
            "nickname": "Milou",
            "full_name": "Loustik Emile",
            "country": null,
            "pivot": {
                "event_id": "1",
                "person_id": "6"
            }
        }
    ],
    "beneficiaries": [
        {
            "id": 3,
            "first_name": "Jean",
            "last_name": "Testing",
            "full_name": "Testing Jean",
            "country": null,
            "pivot": {
                "event_id": "1",
                "person_id": "3"
            }
        },
        {
            "id": 4,
            "first_name": "Raoul",
            "last_name": "Cool",
            "full_name": "Cool Raoul",
            "country": null,
            "pivot": {
                "event_id": "1",
                "person_id": "4"
            }
        }
    ],
    "materials": [
        {
            "id": 3,
            "name": "Yamaha M7CL",
            "description": "La grosse berta new age",
            "reference": "M7CL",
            "park_id": 1,
            "category_id": 1,
            "sub_category_id": 1,
            "rental_price": 75.55,
            "stock_quantity": 5,
            "out_of_order_quantity": null,
            "replacement_price": 525.35,
            "serial_number": null,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "park": {
                "id": 1,
                "name": "default"
            },
            "category": {
                "id": 1,
                "name": "Son"
            },
            "sub_category": {
                "id": 1,
                "name": "Consoles de mix",
                "category_id": 1
            },
            "attributes": [],
            "pivot": {
                "event_id": 1,
                "material_id": 3,
                "quantity": 1
            }
        },
        {
            "id": 5,
            "name": "Chevin Q6 (4 ch.)",
            "description": "Un ampli 4 canaux bien sympa",
            "reference": "AMPQ6",
            "park_id": 1,
            "category_id": 1,
            "sub_category_id": 3,
            "rental_price": 10.25,
            "stock_quantity": 2,
            "out_of_order_quantity": null,
            "replacement_price": 580,
            "serial_number": null,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "park": {
                "id": 1,
                "name": "default"
            },
            "category": {
                "id": 1,
                "name": "Son"
            },
            "sub_category": {
                "id": 3,
                "name": "Amplificateurs",
                "category_id": 1
            },
            "attributes": [],
            "pivot": {
                "event_id": 1,
                "material_id": 5,
                "quantity": 1
            }
        },
        {
            "id": 7,
            "name": "Micro SM58",
            "description": "Le micro de toutes les situations !",
            "reference": "SM58",
            "park_id": 1,
            "category_id": 1,
            "sub_category_id": 18,
            "rental_price": 8,
            "stock_quantity": 16,
            "out_of_order_quantity": 1,
            "replacement_price": 200,
            "serial_number": null,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "park": {
                "id": 1,
                "name": "default"
            },
            "category": {
                "id": 1,
                "name": "Son"
            },
            "sub_category": {
                "id": 18,
                "name": "Micros",
                "category_id": 1
            },
            "attributes": [],
            "pivot": {
                "event_id": 1,
                "material_id": 7,
                "quantity": 1
            }
        }
    ]
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 1,
    "user_id": 1,
    "title": "C'est noël",
    "description": null,
    "start_date": "2018-12-24 00:00:00",
    "end_date": "2018-12-25 23:59:59",
    "is_confirmed": true,
    "location": "Dijon, France",
    "user": {
        "id": 2,
        "pseudo": "newuser",
        "email": "newuser@robertmanager.org",
        "group_id": "member",
        "person": {
            "id": 3,
            "user_id": 2,
            "first_name": "Member",
            "last_name": "Test",
            "nickname": null,
            "email": null,
            "phone": null,
            "street": null,
            "postal_code": null,
            "locality": null,
            "country_id": null,
            "company_id": null,
            "note": null,
            "created_at": "2019-01-13 12:15:01",
            "updated_at": "2019-01-13 12:15:01",
            "deleted_at": null,
            "full_name": "Test Member",
            "country": null
        }
    },
    "beneficiaries": [],
    "assignees": [],
    "materials": [],
    "created_at": "2018-12-31 12:42:12",
    "updated_at": "2018-12-31 16:25:15",
    "deleted_at": null
}

Get all events

Retreive all the events in the application, sorted by start date, and within pagination.

GET /api/events HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X GET -H "Content-Type: application/json" "http://robert2-api.dev/api/events"
Example: GET http://robert2-api.dev/api/events
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "pagination": {
        "current_page": 1,
        "first_page_url": "/api/events?page=1",
        "from": 1,
        "last_page": 1,
        "last_page_url": "/api/events?page=1",
        "next_page_url": null,
        "path": "/api/events",
        "per_page": 100,
        "prev_page_url": null,
        "to": 2,
        "total": 2
    },
    "data": [
        {
            "id": 1,
            "user_id": 1,
            "title": "C'est noël",
            "description": null,
            "start_date": "2018-12-24 00:00:00",
            "end_date": "2018-12-25 23:59:59",
            "is_confirmed": true,
            "location": "Dijon, France",
            "created_at": "2018-12-31 12:42:12",
            "updated_at": "2018-12-31 16:25:15",
            "deleted_at": null
        },
        {
            "id": 2,
            "user_id": 1,
            "title": "Nouvel an",
            "description": null,
            "start_date": "2018-12-31 00:00:00",
            "end_date": "2019-01-01 23:59:59",
            "is_confirmed": true,
            "location": "Marseille",
            "created_at": "2018-12-31 16:22:00",
            "updated_at": "2018-12-31 16:22:00",
            "deleted_at": null
        }
    ]
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "pagination": {
        "current_page": 1,
        "first_page_url": "/api/events?deleted=1&page=1",
        "from": 1,
        "last_page": 1,
        "last_page_url": "/api/events?deleted=1&page=1",
        "next_page_url": null,
        "path": "/api/events",
        "per_page": 100,
        "prev_page_url": null,
        "to": 1,
        "total": 1
    },
    "data": [
        {
            "id": 3,
            "user_id": 1,
            "title": "Soft deleted",
            "description": null,
            "start_date": "2018-12-31 00:00:00",
            "end_date": "2019-01-01 23:59:59",
            "is_confirmed": true,
            "location": "Lyon",
            "created_at": "2019-01-13 11:45:48",
            "updated_at": "2019-01-13 11:46:04",
            "deleted_at": "2019-01-13 11:46:04"
        }
    ]
}

Get one event

Retreive one event with all informations: its User and Person creator’s data, all its Materials (with quantity assigned in pivot), and its Assignees and Beneficiaries.

GET /api/events/1 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X GET -H "Content-Type: application/json" "http://robert2-api.dev/api/events/1"
Example: GET http://robert2-api.dev/api/events/1
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 1,
    "user_id": 1,
    "title": "C'est noël",
    "description": null,
    "start_date": "2018-12-24 00:00:00",
    "end_date": "2018-12-25 23:59:59",
    "is_confirmed": true,
    "location": "Dijon, France",
    "created_at": "2018-12-31 12:42:12",
    "updated_at": "2018-12-31 16:25:15",
    "deleted_at": null,
    "user": {
        "id": 2,
        "pseudo": "member",
        "email": "crew-member@robertmanager.org",
        "group_id": "member",
        "person": {
            "id": 2,
            "user_id": 2,
            "first_name": "Member",
            "last_name": "Technician",
            "nickname": null,
            "email": null,
            "phone": null,
            "street": null,
            "postal_code": null,
            "locality": null,
            "country_id": null,
            "company_id": null,
            "note": null,
            "created_at": "2018-12-26 23:05:53",
            "updated_at": "2018-12-26 23:05:53",
            "deleted_at": null,
            "full_name": "Technician Member",
            "country": null
        }
    },
    "assignees": [
        {
            "id": 2,
            "first_name": "Member",
            "last_name": "Technician",
            "nickname": null,
            "full_name": "Technician Member",
            "country": null,
            "pivot": {
                "event_id": "1",
                "person_id": "2"
            }
        }
    ],
    "beneficiaries": [
        {
            "id": 3,
            "first_name": "Customer",
            "last_name": "Client",
            "full_name": "Client Customer",
            "country": null,
            "pivot": {
                "event_id": "1",
                "person_id": "3"
            }
        }
    ],
    "materials": [
        {
            "id": 2,
            "name": "New matos",
            "description": "Nouveau matos de ouf",
            "reference": "newmatos01",
            "park_id": 1,
            "rental_price": 10,
            "stock_quantity": 5,
            "out_of_order_quantity": null,
            "replacement_price": 525,
            "serial_number": null,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "tags": [],
            "attributes": [],
            "pivot": {
                "event_id": 1,
                "material_id": 2,
                "quantity": 1
            }
        }
    ]
}
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}

Get event's missing materials

Retreive the missing materials for the period of an event. This is usefull to know what materials must be aquired before the event begins.

GET /api/events/6/missing-materials HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X GET -H "Content-Type: application/json" "http://robert2-api.dev/api/events/6/missing-materials"
Example: GET http://robert2-api.dev/api/events/6/missing-materials
Status 200 OK
Content-Type application/json
[
    {
        "id": 242,
        "name": "1 16Amono male vers1 pc 16A femelle",
        "description": null,
        "reference": "adaptri camping 16mono-PC16",
        "park_id": 1,
        "category_id": 2,
        "sub_category_id": null,
        "rental_price": 1,
        "stock_quantity": 7,
        "out_of_order_quantity": 0,
        "replacement_price": 30,
        "serial_number": null,
        "is_hidden_on_bill": false,
        "is_discountable": true,
        "tags": [],
        "attributes": [],
        "pivot": {
            "event_id": 6,
            "material_id": 242,
            "quantity": 7
        },
        "remaining_quantity": -4
    },
    {
        "id": 241,
        "name": "1 32Amono male vers 2 pc 16A femelle",
        "description": null,
        "reference": "adaptri 32mono-2xPC16",
        "park_id": 1,
        "category_id": 2,
        "sub_category_id": null,
        "rental_price": 0.1,
        "stock_quantity": 2,
        "out_of_order_quantity": 0,
        "replacement_price": 30,
        "serial_number": null,
        "is_hidden_on_bill": false,
        "is_discountable": true,
        "tags": [
            {
                "id": 1,
                "name": "Tout neuf"
            }
        ],
        "attributes": [],
        "pivot": {
            "event_id": 6,
            "material_id": 241,
            "quantity": 1
        },
        "remaining_quantity": -1
    }
]
Status 404 Not Found
Content-Type application/json
{
    "success": false,
    "error": {
        "requested": "(GET) http://robert2-api.nostromo/api/events/999/missing-materials",
        "code": 404,
        "message": "The required resource was not found.",
        "file": "/home/polo/WEB/perso/Robert2-api/src/App/Controllers/EventController.php, line 63."
    }
}
Status 200 OK
Content-Type application/json
[]

Delete an event

Remove an event using its ID.

Works in 2 steps:

  • First call to this request: sets the deleted_at field with current date and time.
  • Second call: actually delete the item from database.
DELETE /api/events/1 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X DELETE -H "Content-Type: application/json" "http://robert2-api.dev/api/events/1"
Example: DELETE http://robert2-api.dev/api/events/1
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 1,
    "user_id": 1,
    "title": "C'est noël",
    "description": null,
    "start_date": "2018-12-24 00:00:00",
    "end_date": "2018-12-25 23:59:59",
    "is_confirmed": true,
    "location": "Dijon, France",
    "created_at": "2018-12-31 12:42:12",
    "updated_at": "2018-12-31 16:40:27",
    "deleted_at": "2018-12-31 16:40:27"
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "destroyed": true
}

Restore an event

Restore an event that was previously soft-deleted.

PUT /api/events/restore/1 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X PUT -H "Content-Type: application/json" "http://robert2-api.dev/api/events/restore/1"
Example: PUT http://robert2-api.dev/api/events/restore/1
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 1,
    "user_id": 1,
    "title": "Soft deleted",
    "description": null,
    "start_date": "2018-12-31 00:00:00",
    "end_date": "2019-01-01 23:59:59",
    "is_confirmed": true,
    "location": "Lyon",
    "created_at": "2019-01-13 11:45:48",
    "updated_at": "2019-01-13 16:37:26",
    "deleted_at": null
}

Materials

Materials are the foundation of the application. It’s basically what’s gonna be rented. A material is defined by a name, a rental price and a stock quantity. It belongs to a Park, a Category and an optional Sub category. It can be linked to several Events and Tags.

Create material

To create a material, all the following fields are required:

  • name
  • reference
  • description
  • park_id
  • category_id
  • rental_price
  • stock_quantity
  • replacement_price

Note that we can create Tags and associate them directly to the newly created material.

POST /api/materials HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json

{
    "name": "Yamaha PM5D",
    "reference": "PM5D",
    "description": "Big numeric mixing console",
    "park_id": 1,
    "category_id": 1,
    "sub_category_id": 1,
    "rental_price": 10,
    "stock_quantity": 5,
    "replacement_price": 525,
    "tags": ["Brand new"]
}
curl -X POST -H "Content-Type: application/json" -d '{
    "name": "Yamaha PM5D",
    "reference": "PM5D",
    "description": "Big numeric mixing console",
    "park_id": 1,
    "category_id": 1,
    "sub_category_id": 1,
    "rental_price": 10,
    "stock_quantity": 5,
    "replacement_price": 525,
    "tags": ["Brand new"]
}' "http://robert2-api.dev/api/materials"
Example: POST http://robert2-api.dev/api/materials
Status 400 Bad Request
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": {
            "name": [
                "name must have a length between 2 and 255"
            ],
            "reference": [
                "reference must have a length between 2 and 64"
            ],
            "park_id": [
                "park_id must be numeric"
            ],
            "category_id": [
                "category_id must be numeric"
            ],
            "sub_category_id": [
                "sub_category_id must be numeric"
            ],
            "rental_price": [
                "rental_price must be a float number"
            ],
            "stock_quantity": [
                "stock_quantity must be an integer number"
            ],
            "replacement_price": [
                "replacement_price must be a float number"
            ]
        }
    }
}
Status 409 Conflict
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": []
    }
}
Status 201 Created
Content-Type application/json;charset=utf-8
{
    "name": "Yamaha PM5D",
    "reference": "PM5D",
    "description": "Big numeric mixing console",
    "park_id": 1,
    "category_id": 1,
    "sub_category_id": 1,
    "rental_price": 10,
    "stock_quantity": 5,
    "replacement_price": 5250,
    "is_hidden_on_bill": false,
    "is_discountable": true,
    "updated_at": "2018-12-31 16:49:31",
    "created_at": "2018-12-31 16:49:31",
    "id": 4,
    "park": {
        "id": 1,
        "name": "default"
    },
    "category": {
        "id": 1,
        "name": "sound"
    },
    "sub_category": {
        "id": 1,
        "name": "Mix",
        "category_id": 1
    },
    "attributes": []
}

Update material

Modify material informations.

PUT /api/materials/4 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json

{
    "name": "Console Yamaha PM5D"
}
curl -X PUT -H "Content-Type: application/json" -d '{
    "name": "Console Yamaha PM5D"
}' "http://robert2-api.dev/api/materials/4"
Example: PUT http://robert2-api.dev/api/materials/4
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}
Status 400 Bad Request
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": {
            "name": [
                "name must have a length between 2 and 255"
            ],
            "reference": [
                "reference must have a length between 2 and 64"
            ],
            "park_id": [
                "park_id must be numeric"
            ],
            "category_id": [
                "category_id must be numeric"
            ],
            "sub_category_id": [
                "sub_category_id must be numeric"
            ],
            "rental_price": [
                "rental_price must be a float number"
            ],
            "stock_quantity": [
                "stock_quantity must be an integer number"
            ],
            "replacement_price": [
                "replacement_price must be a float number"
            ]
        }
    }
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 2,
    "name": "Console Yamaha PM5D",
    "description": "Big numeric mixing console",
    "reference": "PM5D",
    "park_id": 1,
    "category_id": 1,
    "sub_category_id": 1,
    "rental_price": 10,
    "stock_quantity": 5,
    "out_of_order_quantity": null,
    "replacement_price": 5250,
    "serial_number": null,
    "is_hidden_on_bill": false,
    "is_discountable": true,
    "note": null,
    "created_at": "2018-12-31 16:49:31",
    "updated_at": "2018-12-31 16:52:07",
    "deleted_at": null,
    "park": {
        "id": 1,
        "name": "default"
    },
    "category": {
        "id": 1,
        "name": "sound"
    },
    "sub_category": {
        "id": 1,
        "name": "Mix",
        "category_id": 1
    },
    "attributes": []
}

Get all materials

Retreive all materials of the application, with their related tags, and custom attributes. The results are paginated, and it’s possible to filter and sort them, as well as apply a search term.

GET /api/materials?whileEvent=1&search=&limit=100&ascending=1&page=1&byColumn=0&orderBy=name&park=1&category=2&subCategory=8&onlySelectedInEvent=1 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X GET -H "Content-Type: application/json" "http://robert2-api.dev/api/materials?whileEvent=1&search=&limit=100&ascending=1&page=1&byColumn=0&orderBy=name&park=1&category=2&subCategory=8&onlySelectedInEvent=1"
Example: GET http://robert2-api.dev/api/materials?whileEvent=1&search=&limit=100&ascending=1&page=1&byColumn=0&orderBy=name&park=1&category=2&subCategory=8&onlySelectedInEvent=1
Status 200 OK
Content-Type application/json
{
    "pagination": {
        "current_page": 1,
        "first_page_url": "/api/materials?search=ampli&orderBy=name&ascending=1&limit=100&page=1",
        "from": 1,
        "last_page": 1,
        "last_page_url": "/api/materials?search=ampli&orderBy=name&ascending=1&limit=100&page=1",
        "next_page_url": null,
        "path": "/api/materials",
        "per_page": 100,
        "prev_page_url": null,
        "to": 16,
        "total": 16
    },
    "data": [
        {
            "id": 3,
            "name": "Ampli 4 voies Chevin Q6",
            "description": null,
            "reference": "Amp Q6",
            "park_id": 1,
            "category_id": 1,
            "sub_category_id": 3,
            "rental_price": 30,
            "stock_quantity": 3,
            "out_of_order_quantity": 0,
            "replacement_price": 2800,
            "serial_number": null,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "note": null,
            "created_at": "2019-10-20 19:31:50",
            "updated_at": "2019-10-20 23:46:37",
            "deleted_at": null,
            "tags": [
                {
                    "id": 7,
                    "name": "Vieux matos"
                }
            ],
            "attributes": []
        },
        {
            "id": 201,
            "name": "Ampli Basse Ampeg (baffle + ampli)",
            "description": null,
            "reference": "Ampeg",
            "park_id": 16,
            "category_id": 1,
            "sub_category_id": 3,
            "rental_price": 35,
            "stock_quantity": 1,
            "out_of_order_quantity": 0,
            "replacement_price": 3000,
            "serial_number": null,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "note": null,
            "created_at": "2019-10-20 19:31:52",
            "updated_at": "2019-10-20 23:46:52",
            "deleted_at": null,
            "tags": [],
            "attributes": []
        },
        {
            "id": 218,
            "name": "Ampli NXAMP Nexo 4 x 1KW",
            "description": null,
            "reference": "NXAMP 4x1",
            "park_id": 1,
            "category_id": 1,
            "sub_category_id": null,
            "rental_price": 40,
            "stock_quantity": 3,
            "out_of_order_quantity": 0,
            "replacement_price": 3000,
            "serial_number": null,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "note": null,
            "created_at": "2019-10-20 19:31:52",
            "updated_at": "2019-10-20 19:31:52",
            "deleted_at": null,
            "tags": [],
            "attributes": []
        },
        {
            "id": 95,
            "name": "Ampli NXAMP Nexo 4 x 4 Kx",
            "description": null,
            "reference": "NXAmp 4x4",
            "park_id": 1,
            "category_id": 1,
            "sub_category_id": null,
            "rental_price": 80,
            "stock_quantity": 1,
            "out_of_order_quantity": 0,
            "replacement_price": 8000,
            "serial_number": null,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "note": null,
            "created_at": "2019-10-20 19:31:51",
            "updated_at": "2019-10-20 19:31:51",
            "deleted_at": null,
            "tags": [],
            "attributes": []
        },
        {
            "id": 4,
            "name": "Ampli QSC pour ligne 100V",
            "description": null,
            "reference": "Amp 100V",
            "park_id": 1,
            "category_id": 1,
            "sub_category_id": 3,
            "rental_price": 25,
            "stock_quantity": 1,
            "out_of_order_quantity": 0,
            "replacement_price": 1200,
            "serial_number": null,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "note": null,
            "created_at": "2019-10-20 19:31:50",
            "updated_at": "2019-10-20 23:46:28",
            "deleted_at": null,
            "tags": [],
            "attributes": []
        },
        {
            "id": 321,
            "name": "Amplificateur LA8 4 Canaux pour Arc Focus & SB 18 L-Acoustic",
            "description": null,
            "reference": "LA8 ampli Arc focus SB 18",
            "park_id": 11,
            "category_id": 1,
            "sub_category_id": null,
            "rental_price": 40,
            "stock_quantity": 2,
            "out_of_order_quantity": 0,
            "replacement_price": 5000,
            "serial_number": null,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "note": null,
            "created_at": "2019-10-20 19:31:53",
            "updated_at": "2019-10-20 19:31:53",
            "deleted_at": null,
            "tags": [],
            "attributes": []
        },
        {
            "id": 209,
            "name": "Amplifié L-Acoustics MTD 108P",
            "description": null,
            "reference": "MTD108P",
            "park_id": 11,
            "category_id": 1,
            "sub_category_id": 2,
            "rental_price": 37,
            "stock_quantity": 4,
            "out_of_order_quantity": 0,
            "replacement_price": 3000,
            "serial_number": null,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "note": null,
            "created_at": "2019-10-20 19:31:52",
            "updated_at": "2019-10-20 23:49:50",
            "deleted_at": null,
            "tags": [],
            "attributes": []
        },
        {
            "id": 174,
            "name": "Amplifiée L-Acoustics MTD112p",
            "description": null,
            "reference": "MTD112P",
            "park_id": 11,
            "category_id": 1,
            "sub_category_id": 2,
            "rental_price": 37,
            "stock_quantity": 2,
            "out_of_order_quantity": 0,
            "replacement_price": 3000,
            "serial_number": null,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "note": null,
            "created_at": "2019-10-20 19:31:51",
            "updated_at": "2019-10-20 23:50:11",
            "deleted_at": null,
            "tags": [],
            "attributes": []
        },
        {
            "id": 207,
            "name": "Enceinte amplifiée Béta3 (the box pa502a)",
            "description": null,
            "reference": "Beta3 ",
            "park_id": 1,
            "category_id": 1,
            "sub_category_id": null,
            "rental_price": 20,
            "stock_quantity": 2,
            "out_of_order_quantity": 0,
            "replacement_price": 500,
            "serial_number": null,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "note": null,
            "created_at": "2019-10-20 19:31:52",
            "updated_at": "2019-10-20 19:31:52",
            "deleted_at": null,
            "tags": [],
            "attributes": []
        },
        {
            "id": 279,
            "name": "Enceinte amplifiée de retour DB Technology FM12",
            "description": null,
            "reference": "FM12",
            "park_id": 1,
            "category_id": 1,
            "sub_category_id": null,
            "rental_price": 20,
            "stock_quantity": 6,
            "out_of_order_quantity": 0,
            "replacement_price": 500,
            "serial_number": null,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "note": null,
            "created_at": "2019-10-20 19:31:52",
            "updated_at": "2019-10-20 19:31:52",
            "deleted_at": null,
            "tags": [],
            "attributes": []
        },
        {
            "id": 313,
            "name": "Enceinte Amplifiée Façade Meyer Sound CQ1-P",
            "description": null,
            "reference": "Meyer CQ1-P",
            "park_id": 13,
            "category_id": 1,
            "sub_category_id": null,
            "rental_price": 70,
            "stock_quantity": 2,
            "out_of_order_quantity": 0,
            "replacement_price": 3000,
            "serial_number": null,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "note": null,
            "created_at": "2019-10-20 19:31:52",
            "updated_at": "2019-10-20 19:31:52",
            "deleted_at": null,
            "tags": [],
            "attributes": []
        },
        {
            "id": 311,
            "name": "Enceinte Amplifiée Façade Meyer Sound UPA-1P",
            "description": null,
            "reference": "Meyer UPA-1P",
            "park_id": 13,
            "category_id": 1,
            "sub_category_id": null,
            "rental_price": 50,
            "stock_quantity": 4,
            "out_of_order_quantity": 0,
            "replacement_price": 2200,
            "serial_number": null,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "note": null,
            "created_at": "2019-10-20 19:31:52",
            "updated_at": "2019-10-20 19:31:52",
            "deleted_at": null,
            "tags": [],
            "attributes": []
        },
        {
            "id": 157,
            "name": "Enceinte amplifiée JBL PRX615",
            "description": null,
            "reference": "PRX615",
            "park_id": 1,
            "category_id": 1,
            "sub_category_id": null,
            "rental_price": 25,
            "stock_quantity": 8,
            "out_of_order_quantity": 0,
            "replacement_price": 900,
            "serial_number": null,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "note": null,
            "created_at": "2019-10-20 19:31:51",
            "updated_at": "2019-10-20 19:31:51",
            "deleted_at": null,
            "tags": [],
            "attributes": []
        },
        {
            "id": 205,
            "name": "enceinte amplifiée Mackie",
            "description": null,
            "reference": "Mackie ",
            "park_id": 1,
            "category_id": 1,
            "sub_category_id": null,
            "rental_price": 15,
            "stock_quantity": 2,
            "out_of_order_quantity": 0,
            "replacement_price": 500,
            "serial_number": null,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "note": null,
            "created_at": "2019-10-20 19:31:52",
            "updated_at": "2019-10-20 19:31:52",
            "deleted_at": null,
            "tags": [],
            "attributes": []
        },
        {
            "id": 210,
            "name": "Sub Amplifié L-Acoustics MTD 15P",
            "description": null,
            "reference": "MTD15P",
            "park_id": 11,
            "category_id": 1,
            "sub_category_id": 2,
            "rental_price": 37,
            "stock_quantity": 2,
            "out_of_order_quantity": 0,
            "replacement_price": 3000,
            "serial_number": null,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "note": null,
            "created_at": "2019-10-20 19:31:52",
            "updated_at": "2019-10-24 12:35:47",
            "deleted_at": null,
            "tags": [],
            "attributes": []
        },
        {
            "id": 309,
            "name": "Wedge db Technologies 12\" Coaxiale Amplifiée 300w",
            "description": null,
            "reference": "Wedge FM12",
            "park_id": 13,
            "category_id": 1,
            "sub_category_id": 2,
            "rental_price": 25,
            "stock_quantity": 10,
            "out_of_order_quantity": 0,
            "replacement_price": 500,
            "serial_number": null,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "note": null,
            "created_at": "2019-10-20 19:31:52",
            "updated_at": "2019-10-24 02:16:36",
            "deleted_at": null,
            "tags": [
                {
                    "id": 1,
                    "name": "Tout neuf"
                }
            ],
            "attributes": []
        }
    ]
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "pagination": {
        "current_page": 1,
        "first_page_url": "/api/materials?deleted=1&page=1",
        "from": 1,
        "last_page": 1,
        "last_page_url": "/api/materials?deleted=1&page=1",
        "next_page_url": null,
        "path": "/api/materials",
        "per_page": 100,
        "prev_page_url": null,
        "to": 1,
        "total": 1
    },
    "data": [
        {
            "id": 3,
            "name": "Yamaha M7CL",
            "description": "Big great numeric mixing console",
            "reference": "M7CL",
            "park_id": 1,
            "category_id": 1,
            "sub_category_id": null,
            "rental_price": 10,
            "stock_quantity": 5,
            "out_of_order_quantity": null,
            "replacement_price": 525,
            "serial_number": null,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "note": "Removed from park because it was sold.",
            "created_at": "2019-01-13 11:56:45",
            "updated_at": "2019-01-13 11:56:56",
            "deleted_at": "2019-01-13 11:56:56",
            "tags": [],
            "attributes": []
        }
    ]
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "pagination": {
        "current_page": 1,
        "first_page_url": "/api/materials?page=1",
        "from": 1,
        "last_page": 1,
        "last_page_url": "/api/materials?page=1",
        "next_page_url": null,
        "path": "/api/materials",
        "per_page": 100,
        "prev_page_url": null,
        "to": 2,
        "total": 2
    },
    "data": [
        {
            "id": 2,
            "name": "Console Yamaha PM5D",
            "description": "Big numeric mixing console",
            "reference": "PM5D",
            "park_id": 1,
            "category_id": 1,
            "sub_category_id": 1,
            "rental_price": 10,
            "stock_quantity": 5,
            "out_of_order_quantity": null,
            "replacement_price": 5250,
            "serial_number": null,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "note": null,
            "created_at": "2018-12-31 16:49:31",
            "updated_at": "2018-12-31 16:52:07",
            "deleted_at": null,
            "tags": [],
            "attributes": []
        },
        {
            "id": 1,
            "name": "New matos",
            "description": "Nouveau matos de ouf",
            "reference": "newmatos01",
            "park_id": 1,
            "category_id": 1,
            "sub_category_id": null,
            "rental_price": 10,
            "stock_quantity": 5,
            "out_of_order_quantity": null,
            "replacement_price": 525,
            "serial_number": null,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "note": null,
            "created_at": "2018-12-31 01:02:12",
            "updated_at": "2018-12-31 01:02:12",
            "deleted_at": null,
            "tags": [],
            "attributes": []
        }
    ]
}
Status 200 OK
Content-Type application/json
{
    "pagination": {
        "current_page": 1,
        "first_page_url": "/api/materials?whileEvent=1&search=tri&limit=100&ascending=1&byColumn=0&orderBy=name&park=1&category=2&subCategory=8&onlySelectedInEvent=1&page=1",
        "from": 1,
        "last_page": 1,
        "last_page_url": "/api/materials?whileEvent=1&search=tri&limit=100&ascending=1&byColumn=0&orderBy=name&park=1&category=2&subCategory=8&onlySelectedInEvent=1&page=1",
        "next_page_url": null,
        "path": "/api/materials",
        "per_page": 100,
        "prev_page_url": null,
        "to": 1,
        "total": 1
    },
    "data": [
        {
            "id": 238,
            "name": "adapt tri p17 32Aagricole male vers p17 32 femelle",
            "description": null,
            "reference": "adaptri 32agric-32",
            "park_id": 1,
            "category_id": 2,
            "sub_category_id": 8,
            "rental_price": 0.1,
            "stock_quantity": 1,
            "out_of_order_quantity": 0,
            "replacement_price": 30,
            "serial_number": null,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "note": null,
            "created_at": "2019-10-20 19:31:52",
            "updated_at": "2019-11-26 23:20:32",
            "deleted_at": null,
            "tags": [],
            "attributes": [],
            "remaining_quantity": 1
        }
    ]
}
Status 200 OK
Content-Type application/json
{
    "pagination": {
        "current_page": 1,
        "first_page_url": "/api/materials?whileEvent=6&page=1",
        "from": 1,
        "last_page": 1,
        "last_page_url": "/api/materials?whileEvent=6&page=1",
        "next_page_url": "/api/materials?whileEvent=6&page=1",
        "path": "/api/materials",
        "per_page": 100,
        "prev_page_url": null,
        "to": 2,
        "total": 2
    },
    "data": [
        {
            "id": 2,
            "name": "Console Yamaha PM5D",
            "description": "Big numeric mixing console",
            "reference": "PM5D",
            "park_id": 1,
            "category_id": 1,
            "sub_category_id": 1,
            "rental_price": 10,
            "stock_quantity": 5,
            "out_of_order_quantity": null,
            "replacement_price": 5250,
            "serial_number": null,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "note": null,
            "created_at": "2018-12-31 16:49:31",
            "updated_at": "2018-12-31 16:52:07",
            "deleted_at": null,
            "tags": [],
            "attributes": [],
            "remaining_quantity": 1
        },
        {
            "id": 1,
            "name": "New matos",
            "description": "Nouveau matos de ouf",
            "reference": "newmatos01",
            "park_id": 1,
            "category_id": 1,
            "sub_category_id": null,
            "rental_price": 10,
            "stock_quantity": 5,
            "out_of_order_quantity": null,
            "replacement_price": 525,
            "serial_number": null,
            "is_hidden_on_bill": false,
            "is_discountable": true,
            "note": null,
            "created_at": "2018-12-31 01:02:12",
            "updated_at": "2018-12-31 01:02:12",
            "deleted_at": null,
            "tags": [],
            "attributes": [],
            "remaining_quantity": 5
        }
    ]
}

Get one material

Retreive one material by its ID, with all its related informations.

GET /api/materials/4 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X GET -H "Content-Type: application/json" "http://robert2-api.dev/api/materials/4"
Example: GET http://robert2-api.dev/api/materials/4
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 2,
    "name": "Console Yamaha PM5D",
    "description": "Big numeric mixing console",
    "reference": "PM5D",
    "park_id": 1,
    "category_id": 1,
    "sub_category_id": 1,
    "rental_price": 10,
    "stock_quantity": 5,
    "out_of_order_quantity": null,
    "replacement_price": 5250,
    "serial_number": null,
    "is_hidden_on_bill": false,
    "is_discountable": true,
    "note": null,
    "created_at": "2018-12-31 16:49:31",
    "updated_at": "2018-12-31 16:52:07",
    "deleted_at": null,
    "tags": [],
    "attributes": []
}

Get a material's Tags

Retreive the list of all tags associated to a given material.

GET /api/materials/2/tags HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X GET -H "Content-Type: application/json" "http://robert2-api.dev/api/materials/2/tags"
Example: GET http://robert2-api.dev/api/materials/2/tags
Status 200 OK
Content-Type application/json;charset=utf-8
[
    {
        "id": 4,
        "name": "Brand new"
    }
]

Delete a material

Remove a material using its ID.

Works in 2 steps:

  • First call to this request: sets the deleted_at field with current date and time.
  • Second call: actually delete the item from database.
DELETE /api/materials/5 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X DELETE -H "Content-Type: application/json" "http://robert2-api.dev/api/materials/5"
Example: DELETE http://robert2-api.dev/api/materials/5
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 5,
    "name": "A big material",
    "description": "Big expensive mixing console",
    "reference": "qwertz",
    "park_id": 1,
    "category_id": 1,
    "sub_category_id": 1,
    "rental_price": 10,
    "stock_quantity": 5,
    "out_of_order_quantity": null,
    "replacement_price": 52,
    "serial_number": null,
    "is_hidden_on_bill": false,
    "is_discountable": true,
    "note": null,
    "created_at": "2018-12-31 17:02:06",
    "updated_at": "2018-12-31 17:02:20",
    "deleted_at": "2018-12-31 17:02:20",
    "tags": [],
    "attributes": []
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "destroyed": true
}

Restore a material

Restore a material that was previously soft-deleted.

PUT /api/materials/restore/1 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X PUT -H "Content-Type: application/json" "http://robert2-api.dev/api/materials/restore/1"
Example: PUT http://robert2-api.dev/api/materials/restore/1
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 1,
    "name": "Yamaha M7CL",
    "description": "Big great numeric mixing console",
    "reference": "M7CL",
    "park_id": 1,
    "category_id": 1,
    "sub_category_id": null,
    "rental_price": 10,
    "stock_quantity": 5,
    "out_of_order_quantity": null,
    "replacement_price": 525,
    "serial_number": null,
    "is_hidden_on_bill": false,
    "is_discountable": true,
    "note": null,
    "created_at": "2019-01-13 11:56:45",
    "updated_at": "2019-01-13 16:39:35",
    "deleted_at": null,
    "tags": [],
    "attributes": []
}

Attributes

Create attribute

To create a material attribute, the following fields are required:

  • name
  • type (must be one of integer, float, string, or boolean)

The fields unit and max_length are optionnal, and the field max_length is only usefull for string type.

POST /api/attributes HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json

{
	"name": "Poids",
	"type": "integer",
	"unit": "kg",
	"max_length": null
}
curl -X POST -H "Content-Type: application/json" -d '{
	"name": "Poids",
	"type": "integer",
	"unit": "kg",
	"max_length": null
}' "http://robert2-api.dev/api/attributes"
Example: POST http://robert2-api.dev/api/attributes
Status 401 Unauthorized
Content-Type application/json
{
    "error": "Unauthorized by ACL: users of group 'member' are not allowed to access this API endpoint."
}
Status 201 Created
Content-Type application/json
{
    "id": 1,
    "name": "Poids",
    "type": "integer",
    "unit": "kg",
    "max_length": null,
    "updated_at": "2019-12-19 23:18:31",
    "created_at": "2019-12-19 23:18:31"
}
Status 400 Bad Request
Content-Type application/json
{
    "success": false,
    "error": {
        "code": 400,
        "message": "Validation failed. See error[details] for more informations.",
        "details": {
            "type": [
                "At least one of these rules must pass for type",
                "type must be equals \"string\"",
                "type must be equals \"integer\"",
                "type must be equals \"float\"",
                "type must be equals \"boolean\""
            ]
        }
    }
}

Get all attributes

Retreive all material’s custom attributes. This is usefull to construct a form allowing to edit materials.

GET /api/materials/attributes HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X GET -H "Content-Type: application/json" "http://robert2-api.dev/api/materials/attributes"
Example: GET http://robert2-api.dev/api/materials/attributes
Status 200 OK
Content-Type application/json
[
    {
        "id": 2,
        "name": "Puissance",
        "type": "float",
        "unit": "W",
        "max_length": null,
        "created_at": "2019-12-18 00:13:24",
        "updated_at": "2019-12-18 00:13:24",
        "deleted_at": null
    },
    {
        "id": 1,
        "name": "Poids",
        "type": "integer",
        "unit": "kg",
        "max_length": null,
        "created_at": "2019-12-19 23:18:31",
        "updated_at": "2019-12-19 23:18:31",
        "deleted_at": null
    }
]

Parks

A Park is basically a set of Materials. It’s defined by just a name. The application must always have at least one park in its database, because all materials necessarily belong to a park.

Create park

Just give a name, and park is added!

POST /api/parks HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json

{
    "name": "New Park"
}
curl -X POST -H "Content-Type: application/json" -d '{
    "name": "New Park"
}
' "http://robert2-api.dev/api/parks"
Example: POST http://robert2-api.dev/api/parks
Status 400 Bad Request
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": {
            "name": [
                "name must not be empty",
                "name must contain only letters (a-z)",
                "name must have a length between 4 and 96"
            ]
        }
    }
}
Status 201 Created
Content-Type application/json;charset=utf-8
{
    "id": 2,
    "name": "New Park",
    "updated_at": "2018-12-31 17:14:55",
    "created_at": "2018-12-31 17:14:55"
}
Status 409 Conflict
Date Mon, 31 Dec 2018 16:13:57 GMT
Server Apache/2.4.29 (Ubuntu)
Content-Length 470
Keep-Alive timeout=5, max=99
Connection Keep-Alive
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": []
    }
}

Update park

Modify a park’s name.

PUT /api/parks/2 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json

{
    "name": "Modified Park"
}
curl -X PUT -H "Content-Type: application/json" -d '{
    "name": "Modified Park"
}
' "http://robert2-api.dev/api/parks/2"
Example: PUT http://robert2-api.dev/api/parks/2
Status 400 Bad Request
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": {
            "name": [
                "name must not be empty",
                "name must contain only letters (a-z)",
                "name must have a length between 4 and 96"
            ]
        }
    }
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 2,
    "name": "Modified Park",
    "created_at": "2018-12-31 17:14:55",
    "updated_at": "2018-12-31 17:16:59",
    "deleted_at": null
}
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}

Get all parks

Retreive all the parks in the application, sorted by start date, and within pagination.

GET /api/parks HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X GET -H "Content-Type: application/json" "http://robert2-api.dev/api/parks"
Example: GET http://robert2-api.dev/api/parks
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "pagination": {
        "current_page": 1,
        "first_page_url": "/api/parks?deleted=1&page=1",
        "from": 1,
        "last_page": 1,
        "last_page_url": "/api/parks?deleted=1&page=1",
        "next_page_url": null,
        "path": "/api/parks",
        "per_page": 100,
        "prev_page_url": null,
        "to": 1,
        "total": 1
    },
    "data": [
        {
            "id": 2,
            "name": "Old Park (destroyed)",
            "created_at": "2019-01-13 12:11:02",
            "updated_at": "2019-01-13 12:11:07",
            "deleted_at": "2019-01-13 12:11:07"
        }
    ]
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "pagination": {
        "current_page": 1,
        "first_page_url": "/api/parks?page=1",
        "from": 1,
        "last_page": 1,
        "last_page_url": "/api/parks?page=1",
        "next_page_url": null,
        "path": "/api/parks",
        "per_page": 100,
        "prev_page_url": null,
        "to": 2,
        "total": 2
    },
    "data": [
        {
            "id": 1,
            "name": "default",
            "created_at": null,
            "updated_at": null,
            "deleted_at": null
        },
        {
            "id": 2,
            "name": "Modified Park",
            "created_at": "2018-12-31 17:14:55",
            "updated_at": "2018-12-31 17:16:59",
            "deleted_at": null
        }
    ]
}

Get one park

Retreive one park.

GET /api/parks/2 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X GET -H "Content-Type: application/json" "http://robert2-api.dev/api/parks/2"
Example: GET http://robert2-api.dev/api/parks/2
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 2,
    "name": "Modified Park",
    "created_at": "2018-12-31 17:14:55",
    "updated_at": "2018-12-31 17:16:59",
    "deleted_at": null
}
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}

Get a park's materials

Retreive the list of all the materials that are associated to the given park.

GET /api/parks/1/materials HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X GET -H "Content-Type: application/json" "http://robert2-api.dev/api/parks/1/materials"
Example: GET http://robert2-api.dev/api/parks/1/materials
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "pagination": {
        "current_page": 1,
        "first_page_url": "/api/parks/1/materials?page=1",
        "from": 1,
        "last_page": 1,
        "last_page_url": "/api/parks/1/materials?page=1",
        "next_page_url": null,
        "path": "/api/parks/1/materials",
        "per_page": 100,
        "prev_page_url": null,
        "to": 2,
        "total": 2
    },
    "data": [
        {
            "id": 2,
            "name": "New matos",
            "description": "Nouveau matos de ouf",
            "reference": "newmatos01",
            "park_id": 1,
            "category_id": 1,
            "sub_category_id": null,
            "rental_price": 10,
            "stock_quantity": 5,
            "out_of_order_quantity": null,
            "replacement_price": 525,
            "serial_number": null,
            "is_hidden_on_bill": false,
            "note": null,
            "created_at": "2018-12-31 01:02:12",
            "updated_at": "2018-12-31 01:02:12",
            "deleted_at": null,
            "park": {
                "id": 1,
                "name": "default"
            },
            "category": {
                "id": 1,
                "name": "sound"
            },
            "sub_category": null
        },
        {
            "id": 1,
            "name": "Console Yamaha PM5D",
            "description": "Big numeric mixing console",
            "reference": "PM5D",
            "park_id": 1,
            "category_id": 1,
            "sub_category_id": 1,
            "rental_price": 10,
            "stock_quantity": 5,
            "out_of_order_quantity": null,
            "replacement_price": 5250,
            "serial_number": null,
            "is_hidden_on_bill": false,
            "note": null,
            "created_at": "2018-12-31 16:49:31",
            "updated_at": "2018-12-31 16:52:07",
            "deleted_at": null,
            "park": {
                "id": 1,
                "name": "default"
            },
            "category": {
                "id": 1,
                "name": "sound"
            },
            "sub_category": {
                "id": 1,
                "name": "Mix",
                "category_id": 1
            }
        }
    ]
}

Delete a park

Remove a park using its ID.

Works in 2 steps:

  • First call to this request: sets the deleted_at field with current date and time.
  • Second call: actually delete the item from database.

WARNING: This will remove all materials associated to the deleted park!

DELETE /api/parks/2 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X DELETE -H "Content-Type: application/json" "http://robert2-api.dev/api/parks/2"
Example: DELETE http://robert2-api.dev/api/parks/2
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 2,
    "name": "Modified Park",
    "created_at": "2018-12-31 17:14:55",
    "updated_at": "2018-12-31 17:23:02",
    "deleted_at": "2018-12-31 17:23:02"
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "destroyed": true
}
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}

Restore a park

Restore a park that was previously soft-deleted.

PUT /api/parks/restore/2 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X PUT -H "Content-Type: application/json" "http://robert2-api.dev/api/parks/restore/2"
Example: PUT http://robert2-api.dev/api/parks/restore/2
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 2,
    "name": "New Park",
    "created_at": "2019-01-13 12:11:02",
    "updated_at": "2019-01-13 16:40:42",
    "deleted_at": null
}
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}

Persons

Persons are the people. It may or may not be linked to an User. A person is defined by a first name and a last name, and serveral informations are available, like email, phone number or address.

Persons are mainly used in Events: as Beneficiaries to defined an event’s client, or as Assignees to define the people who will work on an event.

Create person

To create a person, the following fields are required:

  • first_name
  • last_name
  • nickname

Note that we can create Tags and associate them directly to the newly created person.

POST /api/persons HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json

{
	"first_name": "Jean",
	"last_name": "Destroy",
	"nickname": "to-be-deleted",
	"tags": ["Emmerdeur"]
}
curl -X POST -H "Content-Type: application/json" -d '{
	"first_name": "Jean",
	"last_name": "Destroy",
	"nickname": "to-be-deleted",
	"tags": ["Emmerdeur"]
}' "http://robert2-api.dev/api/persons"
Example: POST http://robert2-api.dev/api/persons
Status 201 Created
Content-Type application/json;charset=utf-8
{
    "id": 2,
    "first_name": "Member",
    "last_name": "Test",
    "nickname": "to-be-deleted",
    "updated_at": "2018-12-31 17:27:11",
    "created_at": "2018-12-31 17:27:11",
    "full_name": "Test Member",
    "country": null
}
Status 400 Bad Request
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": {
            "first_name": [
                "first_name must not be empty",
                "first_name must contain only letters (a-z) and \"\"&-_'\\\",;./\\\\çàÀâÂäÄèÈéÉêÊëËîÎïÏôÔöÔùÙûÛüÜøØæÆ\"\"",
                "first_name must have a length between 2 and 96"
            ],
            "last_name": [
                "last_name must not be empty",
                "last_name must contain only letters (a-z) and \"\"&-_'\\\",;./\\\\çàÀâÂäÄèÈéÉêÊëËîÎïÏôÔöÔùÙûÛüÜøØæÆ\"\"",
                "last_name must have a length between 2 and 96"
            ],
            "email": [
                "email must be valid email"
            ],
            "phone": [
                "phone must be a valid telephone number"
            ],
            "postal_code": [
                "postal_code must have a length lower than 10"
            ],
            "country_id": [
                "country_id must be numeric"
            ],
            "company_id": [
                "company_id must be numeric"
            ]
        }
    }
}

Update person

Modify a person’s informations.

PUT /api/persons/3 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json

{
	"first_name": "Bilbo",
	"last_name": "Baggins",
    "nickname": "Bilbus"
}
curl -X PUT -H "Content-Type: application/json" -d '{
	"first_name": "Bilbo",
	"last_name": "Baggins",
    "nickname": "Bilbus"
}' "http://robert2-api.dev/api/persons/3"
Example: PUT http://robert2-api.dev/api/persons/3
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 3,
    "user_id": null,
    "first_name": "Bilbo",
    "last_name": "Baggins",
    "nickname": "Bilbus",
    "email": null,
    "phone": null,
    "street": null,
    "postal_code": null,
    "locality": null,
    "country_id": null,
    "company_id": null,
    "note": null,
    "created_at": "2018-12-31 00:52:53",
    "updated_at": "2018-12-31 17:30:21",
    "deleted_at": null,
    "full_name": "Baggins Bilbo",
    "country": null
}
Status 400 Bad Request
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": {
            "first_name": [
                "first_name must not be empty",
                "first_name must contain only letters (a-z) and \"\"&-_'\\\",;./\\\\ÇçàÀâÂäÄèÈéÉêÊëËîÎïÏôÔöÔùÙûÛüÜøØæÆ\"\"",
                "first_name must have a length between 2 and 96"
            ],
            "last_name": [
                "last_name must not be empty",
                "last_name must contain only letters (a-z) and \"\"&-_'\\\",;./\\\\ÇçàÀâÂäÄèÈéÉêÊëËîÎïÏôÔöÔùÙûÛüÜøØæÆ\"\"",
                "last_name must have a length between 2 and 96"
            ],
            "email": [
                "email must be valid email"
            ],
            "phone": [
                "phone must be a valid telephone number"
            ],
            "postal_code": [
                "postal_code must have a length lower than 10"
            ],
            "country_id": [
                "country_id must be numeric"
            ],
            "company_id": [
                "company_id must be numeric"
            ]
        }
    }
}

Get all persons

Retreive all persons of the application, sorted by last name, and within pagination.

GET /api/persons HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X GET -H "Content-Type: application/json" "http://robert2-api.dev/api/persons"
Example: GET http://robert2-api.dev/api/persons
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "pagination": {
        "current_page": 1,
        "first_page_url": "/api/persons?deleted=1&page=1",
        "from": 1,
        "last_page": 1,
        "last_page_url": "/api/persons?deleted=1&page=1",
        "next_page_url": null,
        "path": "/api/persons",
        "per_page": 100,
        "prev_page_url": null,
        "to": 1,
        "total": 1
    },
    "data": [
        {
            "id": 2,
            "user_id": null,
            "first_name": "Jean",
            "last_name": "Destroy",
            "nickname": "to-be-deleted",
            "email": null,
            "phone": null,
            "street": null,
            "postal_code": null,
            "locality": null,
            "country_id": null,
            "company_id": null,
            "note": null,
            "created_at": "2019-01-13 12:12:13",
            "updated_at": "2019-01-13 12:12:29",
            "deleted_at": "2019-01-13 12:12:29",
            "full_name": "Jean Destroy",
            "country": null
        }
    ]
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "pagination": {
        "current_page": 1,
        "first_page_url": "/api/persons?page=1",
        "from": 1,
        "last_page": 1,
        "last_page_url": "/api/persons?page=1",
        "next_page_url": null,
        "path": "/api/persons",
        "per_page": 100,
        "prev_page_url": null,
        "to": 4,
        "total": 4
    },
    "data": [
        {
            "id": 3,
            "user_id": null,
            "first_name": "Bilbo",
            "last_name": "Baggins",
            "nickname": "Bilbus",
            "email": null,
            "phone": null,
            "street": null,
            "postal_code": null,
            "locality": null,
            "country_id": null,
            "company_id": null,
            "note": null,
            "created_at": "2018-12-31 00:52:53",
            "updated_at": "2018-12-31 17:32:43",
            "deleted_at": null,
            "full_name": "Baggins Bilbo",
            "country": null
        },
        {
            "id": 1,
            "user_id": 1,
            "first_name": "Admin",
            "last_name": "Robertus",
            "nickname": null,
            "email": "admin@robertmanager.org",
            "phone": "0654321987",
            "street": "Rue centrale, 42bis",
            "postal_code": "1000",
            "locality": "Lausanne",
            "country_id": null,
            "company_id": null,
            "note": null,
            "created_at": "2018-12-29 19:12:01",
            "updated_at": "2018-12-29 19:12:01",
            "deleted_at": null,
            "full_name": "Robertus Admin",
            "country": null
        }
    ]
}

Get tagged persons

Retreive all persons that have a set of tags, sorted by last name, and within pagination.

GET /api/persons?tag[]=customer&tag[]=friend HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X GET -H "Content-Type: application/json" "http://robert2-api.dev/api/persons?tag[]=customer&tag[]=friend"
Example: GET http://robert2-api.dev/api/persons?tag[]=customer&tag[]=friend
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "pagination": {
        "current_page": 1,
        "first_page_url": "/api/persons?tag[]=customer&tag[]=friend&page=1",
        "from": 1,
        "last_page": 1,
        "last_page_url": "/api/persons?tag[]=customer&tag[]=friend&page=1",
        "next_page_url": null,
        "path": "/api/persons",
        "per_page": 100,
        "prev_page_url": null,
        "to": 1,
        "total": 1
    },
    "data": [
        {
            "id": 3,
            "user_id": null,
            "first_name": "Bilbo",
            "last_name": "Baggins",
            "nickname": "Bilbus",
            "email": null,
            "phone": null,
            "street": null,
            "postal_code": null,
            "locality": null,
            "country_id": null,
            "company_id": null,
            "note": null,
            "created_at": "2018-12-31 00:52:53",
            "updated_at": "2018-12-31 17:32:43",
            "deleted_at": null,
            "full_name": "Baggins Bilbo",
            "country": null
        }
    ]
}

Get one person

Retreive all informations of a given person.

GET /api/persons/2 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X GET -H "Content-Type: application/json" "http://robert2-api.dev/api/persons/2"
Example: GET http://robert2-api.dev/api/persons/2
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 2,
    "user_id": 2,
    "first_name": "Admin",
    "last_name": "Robertus",
    "nickname": null,
    "email": "admin@robertmanager.org",
    "phone": "0654321987",
    "street": "Rue centrale, 42bis",
    "postal_code": "1000",
    "locality": "Lausanne",
    "country_id": null,
    "company_id": null,
    "note": null,
    "created_at": "2018-12-29 19:12:01",
    "updated_at": "2018-12-29 19:12:01",
    "deleted_at": null,
    "full_name": "Robertus Admin",
    "country": null
}

Get a person's tags

Retreive all tags associated to a given person.

GET /api/persons/3/tags HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X GET -H "Content-Type: application/json" "http://robert2-api.dev/api/persons/3/tags"
Example: GET http://robert2-api.dev/api/persons/3/tags
Status 200 OK
Content-Type application/json;charset=utf-8
[
    {
        "id": 2,
        "name": "Customer"
    },
    {
        "id": 3,
        "name": "Friend"
    }
]

Delete a person

Remove a person - Well, hum, just in database, huh? :D - using its ID.

Works in 2 steps:

  • First call to this request: sets the deleted_at field with current date and time.
  • Second call: actually delete the item from database.
DELETE /api/persons/2 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X DELETE -H "Content-Type: application/json" "http://robert2-api.dev/api/persons/2"
Example: DELETE http://robert2-api.dev/api/persons/2
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "destroyed": true
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 7,
    "user_id": null,
    "first_name": "Jean",
    "last_name": "Destroy",
    "nickname": "to-be-deleted",
    "email": null,
    "phone": null,
    "street": null,
    "postal_code": null,
    "locality": null,
    "country_id": null,
    "company_id": null,
    "note": null,
    "created_at": "2018-12-31 17:27:11",
    "updated_at": "2018-12-31 17:42:59",
    "deleted_at": "2018-12-31 17:42:59",
    "full_name": "Destroy Jean",
    "country": null
}

Restore a person

Restore a person that was previously soft-deleted.

PUT /api/persons/restore/2 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X PUT -H "Content-Type: application/json" "http://robert2-api.dev/api/persons/restore/2"
Example: PUT http://robert2-api.dev/api/persons/restore/2
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 2,
    "user_id": null,
    "first_name": "Jean",
    "last_name": "Destroy",
    "nickname": "to-be-deleted",
    "email": null,
    "phone": null,
    "street": null,
    "postal_code": null,
    "locality": null,
    "country_id": null,
    "company_id": null,
    "note": null,
    "created_at": "2019-01-13 12:12:13",
    "updated_at": "2019-01-13 16:43:39",
    "deleted_at": null,
    "full_name": "Destroy Jean",
    "country": null
}
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}

Tags

Tags are a mean to tidy up and sort Materials and Persons. A tag is defined by just a name.

Each Material can have several Tags, and each Tag can have serveral Materials. Same for Persons.

Create tag

Just send the name of a tag, and that’s it!

POST /api/tags HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json

{
    "name": "Vintage"
}
curl -X POST -H "Content-Type: application/json" -d '{
    "name": "Vintage"
}
' "http://robert2-api.dev/api/tags"
Example: POST http://robert2-api.dev/api/tags
Status 201 Created
Content-Type application/json;charset=utf-8
{
    "id": 6,
    "name": "New tag",
    "updated_at": "2018-12-31 15:40:54",
    "created_at": "2018-12-31 15:40:54"
}
Status 400 Bad Request
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": {
            "name": [
                "name must not be empty",
                "name must contain only letters (a-z) and digits (0-9)",
                "name must have a length between 1 and 48"
            ]
        }
    }
}
Status 409 Conflict
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": []
    }
}

Update tag

Modify a tag’s name.

PUT /api/tags/6 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json

{
    "name": "Just modified Tag"
}
curl -X PUT -H "Content-Type: application/json" -d '{
    "name": "Just modified Tag"
}
' "http://robert2-api.dev/api/tags/6"
Example: PUT http://robert2-api.dev/api/tags/6
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 6,
    "name": "Just modified Tag",
    "created_at": "2018-12-31 15:40:54",
    "updated_at": "2018-12-31 15:42:33",
    "deleted_at": null
}
Status 400 Bad Request
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": {
            "name": [
                "name must not be empty",
                "name must contain only letters (a-z) and digits (0-9)",
                "name must have a length between 1 and 48"
            ]
        }
    }
}
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}

Get all tags

Retreive all the tags of the application, sorted by name, and within pagination.

GET /api/tags HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X GET -H "Content-Type: application/json" "http://robert2-api.dev/api/tags"
Example: GET http://robert2-api.dev/api/tags
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "pagination": {
        "current_page": 1,
        "first_page_url": "/api/tags?deleted=1&page=1",
        "from": 1,
        "last_page": 1,
        "last_page_url": "/api/tags?deleted=1&page=1",
        "next_page_url": null,
        "path": "/api/tags",
        "per_page": 100,
        "prev_page_url": null,
        "to": 1,
        "total": 1
    },
    "data": [
        {
            "id": 4,
            "name": "Useless",
            "created_at": "2019-01-13 12:13:43",
            "updated_at": "2019-01-13 12:13:55",
            "deleted_at": "2019-01-13 12:13:55"
        }
    ]
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "pagination": {
        "current_page": 1,
        "first_page_url": "/api/tags?page=1",
        "from": 1,
        "last_page": 1,
        "last_page_url": "/api/tags?page=1",
        "next_page_url": null,
        "path": "/api/tags",
        "per_page": 100,
        "prev_page_url": null,
        "to": 5,
        "total": 5
    },
    "data": [
        {
            "id": 1,
            "name": "Client",
            "created_at": "2018-12-31 00:50:35",
            "updated_at": "2018-12-31 00:50:35",
            "deleted_at": null
        },
        {
            "id": 6,
            "name": "Just modified Tag",
            "created_at": "2018-12-31 15:40:54",
            "updated_at": "2018-12-31 15:42:33",
            "deleted_at": null
        },
        {
            "id": 2,
            "name": "Vintage",
            "created_at": "2018-12-31 00:51:04",
            "updated_at": "2018-12-31 00:51:04",
            "deleted_at": null
        }
    ]
}

Get a tag's people

Retreive all the Persons that have the given tag.

GET /api/tags/1/persons HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X GET -H "Content-Type: application/json" "http://robert2-api.dev/api/tags/1/persons"
Example: GET http://robert2-api.dev/api/tags/1/persons
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "pagination": {
        "current_page": 1,
        "first_page_url": "/api/tags/3/persons?page=1",
        "from": 1,
        "last_page": 1,
        "last_page_url": "/api/tags/3/persons?page=1",
        "next_page_url": null,
        "path": "/api/tags/3/persons",
        "per_page": 100,
        "prev_page_url": null,
        "to": 1,
        "total": 1
    },
    "data": [
        {
            "id": 3,
            "user_id": null,
            "first_name": "Jean",
            "last_name": "Destroy",
            "nickname": "to-be-deleted",
            "email": null,
            "phone": null,
            "street": null,
            "postal_code": null,
            "locality": null,
            "country_id": null,
            "company_id": null,
            "note": null,
            "created_at": "2018-12-31 00:52:53",
            "updated_at": "2018-12-31 00:52:53",
            "deleted_at": null,
            "full_name": "Destroy Jean",
            "country": null,
            "pivot": {
                "tag_id": "1",
                "taggable_id": "3",
                "taggable_type": "Robert2\\API\\Models\\Person"
            }
        }
    ]
}

Get a tag's materials

Retreive all the Materials that have the given tag.

GET /api/tags/4/materials HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X GET -H "Content-Type: application/json" "http://robert2-api.dev/api/tags/4/materials"
Example: GET http://robert2-api.dev/api/tags/4/materials
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "pagination": {
        "current_page": 1,
        "first_page_url": "/api/tags/4/materials?page=1",
        "from": 1,
        "last_page": 1,
        "last_page_url": "/api/tags/4/materials?page=1",
        "next_page_url": null,
        "path": "/api/tags/4/materials",
        "per_page": 100,
        "prev_page_url": null,
        "to": 1,
        "total": 1
    },
    "data": [
        {
            "id": 2,
            "name": "New matos",
            "description": "Nouveau matos de ouf",
            "reference": "newmatos01",
            "park_id": 1,
            "category_id": 1,
            "sub_category_id": null,
            "rental_price": 10,
            "stock_quantity": 5,
            "out_of_order_quantity": null,
            "replacement_price": 525,
            "serial_number": null,
            "is_hidden_on_bill": false,
            "note": null,
            "created_at": "2018-12-31 01:02:12",
            "updated_at": "2018-12-31 01:02:12",
            "deleted_at": null,
            "park": {
                "id": 1,
                "name": "default"
            },
            "category": {
                "id": 1,
                "name": "son"
            },
            "sub_category": null,
            "pivot": {
                "tag_id": "2",
                "taggable_id": "2",
                "taggable_type": "Robert2\\API\\Models\\Material"
            }
        }
    ]
}
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}

Search in tags

Search tags by their name.

GET /api/tags/search?name=cli HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X GET -H "Content-Type: application/json" "http://robert2-api.dev/api/tags/search?name=cli"
Example: GET http://robert2-api.dev/api/tags/search?name=cli
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "pagination": {
        "current_page": 1,
        "first_page_url": "/api/tags/search?name=cli&page=1",
        "from": 1,
        "last_page": 1,
        "last_page_url": "/api/tags/search?name=cli&page=1",
        "next_page_url": null,
        "path": "/api/tags/search",
        "per_page": 100,
        "prev_page_url": null,
        "to": 1,
        "total": 1
    },
    "data": [
        {
            "id": 1,
            "name": "Client",
            "created_at": "2018-12-31 00:50:35",
            "updated_at": "2018-12-31 00:50:35",
            "deleted_at": null
        }
    ]
}

Delete a tag

Remove a tag using its ID.

Works in 2 steps:

  • First call to this request: sets the deleted_at field with current date and time.
  • Second call: actually delete the item from database.
DELETE /api/tags/6 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X DELETE -H "Content-Type: application/json" "http://robert2-api.dev/api/tags/6"
Example: DELETE http://robert2-api.dev/api/tags/6
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "destroyed": true
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 6,
    "name": "Just modified Tag",
    "created_at": "2018-12-31 15:40:54",
    "updated_at": "2018-12-31 15:52:04",
    "deleted_at": "2018-12-31 15:52:04"
}

Restore a tag

Restore a tag that was previously soft-deleted.

PUT /api/tags/restore/6 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X PUT -H "Content-Type: application/json" "http://robert2-api.dev/api/tags/restore/6"
Example: PUT http://robert2-api.dev/api/tags/restore/6
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 6,
    "name": "Useless",
    "created_at": "2019-01-13 12:13:43",
    "updated_at": "2019-01-13 16:45:07",
    "deleted_at": null
}

Users

Users are, well… the users of the application. They are defined by a pseudo, a password, a Group and an email address.

A user can be linked to a Person, in order to provide more informations about her or him.

The Group of an user must be admin, member, or visitor.

User sign up (create)

Create a user, directly with its associated Person.

POST /api/users/signup HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json

{
    "pseudo": "newuser",
    "email": "newuser@robertmanager.org",
    "password": "test",
    "group_id": "member",
    "person": {
    	"first_name": "Member",
    	"last_name": "Test"
    }
}
curl -X POST -H "Content-Type: application/json" -d '{
    "pseudo": "newuser",
    "email": "newuser@robertmanager.org",
    "password": "test",
    "group_id": "member",
    "person": {
    	"first_name": "Member",
    	"last_name": "Test"
    }
}' "http://robert2-api.dev/api/users/signup"
Example: POST http://robert2-api.dev/api/users/signup
Status 201 Created
Content-Type application/json;charset=utf-8
{
    "pseudo": "newuser",
    "email": "newuser@robertmanager.org",
    "group_id": "member",
    "updated_at": "2018-12-31 16:04:26",
    "created_at": "2018-12-31 16:04:26",
    "id": 3,
    "person": {
        "id": 4,
        "user_id": 3,
        "first_name": "Member",
        "last_name": "Test",
        "nickname": null,
        "email": null,
        "phone": null,
        "street": null,
        "postal_code": null,
        "locality": null,
        "country_id": null,
        "company_id": null,
        "note": null,
        "created_at": "2018-12-31 16:04:26",
        "updated_at": "2018-12-31 16:04:26",
        "deleted_at": null,
        "full_name": "Test Member",
        "country": null
    }
}
Status 400 Bad Request
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": {
            "pseudo": [
                "pseudo must not be empty",
                "pseudo must contain only letters (a-z) and digits (0-9)",
                "pseudo must have a length between 4 and 100"
            ],
            "email": [
                "email must be valid email"
            ],
            "group_id": [
                "At least one of these rules must pass for group_id",
                "group_id must be equals \"admin\"",
                "group_id must be equals \"member\"",
                "group_id must be equals \"visitor\""
            ],
            "password": [
                "password must not be empty",
                "password must have a length between 4 and 255"
            ]
        }
    }
}

Update user

Modify user’s pseudo and associated person’s informations.

PUT /api/users/3 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json

{
	"pseudo": "tobedeleted",
    "person": {
    	"first_name": "Remove",
    	"last_name": "Me please"
    }
}
curl -X PUT -H "Content-Type: application/json" -d '{
	"pseudo": "tobedeleted",
    "person": {
    	"first_name": "Remove",
    	"last_name": "Me please"
    }
}' "http://robert2-api.dev/api/users/3"
Example: PUT http://robert2-api.dev/api/users/3
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 3,
    "pseudo": "tobedeleted",
    "email": "removeme@test.org",
    "group_id": "member",
    "created_at": "2018-12-31 16:04:26",
    "updated_at": "2018-12-31 16:08:33",
    "deleted_at": null,
    "person": {
        "id": 4,
        "user_id": 3,
        "first_name": "Me please",
        "last_name": "Remove",
        "nickname": null,
        "email": null,
        "phone": null,
        "street": null,
        "postal_code": null,
        "locality": null,
        "country_id": null,
        "company_id": null,
        "note": null,
        "created_at": "2018-12-31 16:04:26",
        "updated_at": "2018-12-31 16:04:26",
        "deleted_at": null,
        "full_name": "Remove Me please",
        "country": null
    }
}
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}
Status 400 Bad Request
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": {
            "pseudo": [
                "pseudo must not be empty",
                "pseudo must contain only letters (a-z) and digits (0-9)",
                "pseudo must have a length between 4 and 100"
            ],
            "email": [
                "email must be valid email"
            ],
            "group_id": [
                "At least one of these rules must pass for group_id",
                "group_id must be equals \"admin\"",
                "group_id must be equals \"member\"",
                "group_id must be equals \"visitor\""
            ]
        }
    }
}

User sign in (auth token)

This is the exact same endpoint as the AUTH - Token one.

Same payload, same result: give a username and password, and get your access token for the session. For example of responses, see AUTH - Token request documentation.

POST /api/users/signin HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json

{
    "identifier": "admin",
    "password" : "admin"
}
curl -X POST -H "Content-Type: application/json" -d '{
    "identifier": "admin",
    "password" : "admin"
}' "http://robert2-api.dev/api/users/signin"
Example: POST http://robert2-api.dev/api/users/signin
Status 404 Not Found
Content-Type application/json
{
    "success": false,
    "error": {
        "requested": "(POST) http://robert2-api.nostromo/api/users/signin",
        "code": 404,
        "message": "The required resource was not found.",
        "file": "/home/polo/WEB/perso/Robert2-api/src/App/Models/User.php, line 118."
    }
}
Status 200 OK
Cache-Control private, no-cache
Content-Type application/json
{
    "user": {
        "id": 1,
        "pseudo": "admin",
        "email": "admin@robertmanager.org",
        "group_id": "admin",
        "created_at": "2018-12-26 23:05:53",
        "updated_at": "2018-12-26 23:05:53",
        "deleted_at": null,
        "person": {
            "id": 1,
            "user_id": 1,
            "first_name": "Admin",
            "last_name": "Example",
            "nickname": null,
            "email": null,
            "phone": null,
            "street": null,
            "postal_code": null,
            "locality": null,
            "country_id": null,
            "company_id": null,
            "note": null,
            "created_at": "2018-12-26 23:05:53",
            "updated_at": "2018-12-26 23:05:53",
            "deleted_at": null,
            "full_name": "Admin Example",
            "country": null
        }
    },
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE1NDYyMTY5OTMsImV4cCI6MTU0NjIyNDE5MywidXNlciI6eyJpZCI6MSwicHNldWRvIjoicG9sbyIsImVtYWlsIjoicG9sb0Bwb2xvc3Nvbi5jb20iLCJncm91cF9pZCI6ImFkbWluIiwiY3JlYXRlZF9hdCI6IjIwMTgtMTItMjYgMjM6MDU6NTMiLCJ1cGRhdGVkX2F0IjoiMjAxOC0xMi0yNiAyMzowNTo1MyIsImRlbGV0ZWRfYXQiOm51bGwsInBlcnNvbiI6eyJpZCI6MSwidXNlcl9pZCI6MSwiZmlyc3RfbmFtZSI6IlZdfERfLCJsYXN0X25hbWUiOiJNYWlsbGFyZGV0Iiwibmlja25hbWUiOm51bGwsImVtYWlsIjpudWxsLCJwaG9uZSI6bnVsbCwic3RyZWV0IjpudWxsLCJwb3N0YWxfY29kZSI6bnVsbCwibG9jYWxpdHkiOm51bGwsImNvdW50cnlfaWQiOm51bGwsImNvbXBhbnlfaWQiOm51bGwsIm5vdGUiOm51bGwsImNyZWF0ZWRfYXQiOiIyMDE4LTEyLTI2IDIzOjA1OjUzIiwidXBkYXRlZF9hdCI6IjIwMTgtMTItMjYgMjM6MDU6NTMiLCJkZWxldGVkX2F0IjpudWxsLCJmdWxsX25hbWUiOiJQb2xvIE1haWxsYXJkZFrgoMsjb3VudHJ5IjpudWxsfX19.aGlHpQSQ1ftQCd_F3Uq7CtikC-trfs4l0j7xskaLOyU"
}
Status 400 Bad Request
Content-Type application/json
{
    "success": false,
    "error": {
        "code": 400,
        "message": "Validation failed. See error[details] for more informations.",
        "details": {
            "identifier": [
                "Identifier must not be empty"
            ],
            "password": [
                "Password must not be empty",
                "Password must have a length greater than 4"
            ]
        }
    }
}

Get all users

Retreive all users of the application, with their associated Persons, sorted by pseudo, and within pagination.

GET /api/users HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X GET -H "Content-Type: application/json" "http://robert2-api.dev/api/users"
Example: GET http://robert2-api.dev/api/users
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "pagination": {
        "current_page": 1,
        "first_page_url": "/api/users?page=1",
        "from": 1,
        "last_page": 1,
        "last_page_url": "/api/users?page=1",
        "next_page_url": null,
        "path": "/api/users",
        "per_page": 100,
        "prev_page_url": null,
        "to": 2,
        "total": 2
    },
    "data": [
        {
            "id": 1,
            "pseudo": "admin",
            "email": "admin@robertmanager.org",
            "group_id": "admin",
            "created_at": "2018-12-29 19:12:01",
            "updated_at": "2018-12-29 19:12:01",
            "deleted_at": null,
            "person": {
                "id": 2,
                "user_id": 2,
                "first_name": "Admin",
                "last_name": "Robertus",
                "nickname": null,
                "email": null,
                "phone": null,
                "street": null,
                "postal_code": null,
                "locality": null,
                "country_id": null,
                "company_id": null,
                "note": null,
                "created_at": "2018-12-29 19:12:01",
                "updated_at": "2018-12-29 19:12:01",
                "deleted_at": null,
                "full_name": "Robertus Admin",
                "country": null
            }
        },
        {
            "id": 2,
            "pseudo": "tobedeleted",
            "email": "removeme@test.org",
            "group_id": "member",
            "created_at": "2018-12-31 16:04:26",
            "updated_at": "2018-12-31 16:08:33",
            "deleted_at": null,
            "person": {
                "id": 4,
                "user_id": 3,
                "first_name": "Me please",
                "last_name": "Remove",
                "nickname": null,
                "email": null,
                "phone": null,
                "street": null,
                "postal_code": null,
                "locality": null,
                "country_id": null,
                "company_id": null,
                "note": null,
                "created_at": "2018-12-31 16:04:26",
                "updated_at": "2018-12-31 16:04:26",
                "deleted_at": null,
                "full_name": "Remove Me please",
                "country": null
            }
        }
    ]
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "pagination": {
        "current_page": 1,
        "first_page_url": "/api/users?deleted=1&page=1",
        "from": 1,
        "last_page": 1,
        "last_page_url": "/api/users?deleted=1&page=1",
        "next_page_url": null,
        "path": "/api/users",
        "per_page": 100,
        "prev_page_url": null,
        "to": 1,
        "total": 1
    },
    "data": [
        {
            "id": 2,
            "pseudo": "newuser",
            "email": "newuser@robertmanager.org",
            "group_id": "member",
            "created_at": "2019-01-13 12:15:01",
            "updated_at": "2019-01-13 12:15:13",
            "deleted_at": "2019-01-13 12:15:13",
            "person": {
                "id": 3,
                "user_id": 2,
                "first_name": "Member",
                "last_name": "Test",
                "nickname": null,
                "email": null,
                "phone": null,
                "street": null,
                "postal_code": null,
                "locality": null,
                "country_id": null,
                "company_id": null,
                "note": null,
                "created_at": "2019-01-13 12:15:01",
                "updated_at": "2019-01-13 12:15:01",
                "deleted_at": null,
                "full_name": "Member Test",
                "country": null
            }
        }
    ]
}

Get one user

Retreive one user with its associated Person.

GET /api/users/2 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X GET -H "Content-Type: application/json" "http://robert2-api.dev/api/users/2"
Example: GET http://robert2-api.dev/api/users/2
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 2,
    "pseudo": "tobedeleted",
    "email": "removeme@test.org",
    "group_id": "member",
    "created_at": "2018-12-31 16:04:26",
    "updated_at": "2018-12-31 16:08:33",
    "deleted_at": null,
    "person": {
        "id": 4,
        "user_id": 3,
        "first_name": "Me please",
        "last_name": "Remove",
        "nickname": null,
        "email": null,
        "phone": null,
        "street": null,
        "postal_code": null,
        "locality": null,
        "country_id": null,
        "company_id": null,
        "note": null,
        "created_at": "2018-12-31 16:04:26",
        "updated_at": "2018-12-31 16:04:26",
        "deleted_at": null,
        "full_name": "Remove Me please",
        "country": null
    }
}
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}

Get user settings

Get a user’s settings data.

GET /api/users/1/settings HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X GET -H "Content-Type: application/json" "http://robert2-api.dev/api/users/1/settings"
Example: GET http://robert2-api.dev/api/users/1/settings
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 1,
    "user_id": 1,
    "language": "EN",
    "auth_token_validity_duration": 12,
    "created_at": "2019-01-04 00:16:57",
    "updated_at": "2019-01-04 00:16:57"
}
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}

Update user settings

Modify a user’s settings data.

PUT /api/users/1/settings HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json

{
	"language": "FR"
}
curl -X PUT -H "Content-Type: application/json" -d '{
	"language": "FR"
}' "http://robert2-api.dev/api/users/1/settings"
Example: PUT http://robert2-api.dev/api/users/1/settings
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 1,
    "user_id": 1,
    "language": "FR",
    "auth_token_validity_duration": 12,
    "created_at": "2019-01-04 00:16:57",
    "updated_at": "2019-01-04 16:18:25"
}

Delete a user

Remove a tag using its ID.

Works in 2 steps:

  • First call to this request: sets the deleted_at field with current date and time.
  • Second call: actually delete the item from database.
DELETE /api/users/2 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X DELETE -H "Content-Type: application/json" "http://robert2-api.dev/api/users/2"
Example: DELETE http://robert2-api.dev/api/users/2
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "destroyed": true
}
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 2,
    "pseudo": "tobedeleted",
    "email": "removeme@test.org",
    "group_id": "member",
    "password": "$2y$10$wqoEEP7oxcDiH3iqdJ6Lj.RPc4J0n.4egitFXBZxDqsW43csrAyjO",
    "created_at": "2018-12-31 16:04:26",
    "updated_at": "2018-12-31 16:15:17",
    "deleted_at": "2018-12-31 16:15:17",
    "person": {
        "id": 4,
        "user_id": 3,
        "first_name": "Me please",
        "last_name": "Remove",
        "nickname": null,
        "email": null,
        "phone": null,
        "street": null,
        "postal_code": null,
        "locality": null,
        "country_id": null,
        "company_id": null,
        "note": null,
        "created_at": "2018-12-31 16:04:26",
        "updated_at": "2018-12-31 16:04:26",
        "deleted_at": null,
        "full_name": "Remove Me please",
        "country": null
    }
}

Restore a user

Restore a user that was previously soft-deleted.

PUT /api/users/restore/2 HTTP/1.1
Host: robert2-api.dev
Content-Type: application/json
curl -X PUT -H "Content-Type: application/json" "http://robert2-api.dev/api/users/restore/2"
Example: PUT http://robert2-api.dev/api/users/restore/2
Status 200 OK
Content-Type application/json;charset=utf-8
{
    "id": 2,
    "pseudo": "newuser",
    "email": "newuser@robertmanager.org",
    "group_id": "member",
    "password": "$2y$10$1vDPqKOybiEPFAW0i2NwGOe4nUejCZQQhS8JsCg3GGbJ6VpNeJcFS",
    "created_at": "2019-01-13 12:15:01",
    "updated_at": "2019-01-13 16:46:11",
    "deleted_at": null,
    "person": {
        "id": 3,
        "user_id": 2,
        "first_name": "Member",
        "last_name": "Test",
        "nickname": null,
        "email": null,
        "phone": null,
        "street": null,
        "postal_code": null,
        "locality": null,
        "country_id": null,
        "company_id": null,
        "note": null,
        "created_at": "2019-01-13 12:15:01",
        "updated_at": "2019-01-13 12:15:01",
        "deleted_at": null,
        "full_name": "Test Member",
        "country": null
    }
}
Status 404 Not Found
Content-Type application/json;charset=utf-8
{
    "success": false,
    "error": {
        "message": "An error has occured",
        "details": [
            "The required resource was not found."
        ]
    }
}