Introduction

In order to facilitate the implementation of your webservices, we have created turnkey apis to manage some features of applications that we often find (the notion of user through registration, login, recovery apis in profile, managing an authentication token, sending emails ...)

Use these APIs to focus on the business side of your application without having to rethink the issues in many applications.

No need to re-invent the wheel as they say!

API returns

format

Pre-built APIs use the \Lib\Tools::formatError() and \Lib\Tools::formatSuccess() (see section Tools) methods to return a response (except of course in a case where you need to return a result set , and not just an error response or success), so you can have these 2 formats of returns :

//success on a POST, PUT, PATCH or DELETE :

{
  "success": {
    "message": "Request was successful",
    "key": "success",
    "code": 200
  }
}

// error : 

{
  "error": {
    "message": "Id not found.",
    "key": "id_not_found",
    "code": 1
  }
}

http codes

The error codes in 5xx are reserved for the core of the API, and are not adjustable from the webservices of the application.

Through the formatError method you have the possibility to set the error code in the 4xx range (400 by default)

Finally, through the formatSuccess method, you have the possibility to set the success code in the 2xx range (200 by default)