All API functions return data in the following format (after response if decoded):
$response = array(
'status' => '',
'data' => array(),
'message' => '',
'errors' => array()
);
status is a string and its values can be ‘SUCCESS’ or ‘FAILURE’. This value can be used in the code to determine if the API call succeeded or failed.
data is an array of data. It can display in one of two ways:
1. With requests that return one item/model, data is a simple array of item/model properties, for example:
$data = array( 'id'=>'1', 'name'=>'ABC Ins.' );
2. In the scenario where you search model/items, the format of data element is as follows:
$data = array( 'totalCount'=>'20, 'currentPage'=>1, 'items'=>array( array( 'id'=>'1', 'name'=>'ABC Ins.' ), array( 'id'=>'5', 'name'=>'CBA Ins.' ), ... ); );
message is a string that contains a response message.
errors is an array of errors that is displayed if the API call failed. For example if you are trying to create a new contact without providing all required data, you will get array of required fields.
Comments