Hello Community,
Happy New Year 2016 .
Ref: http://docs.cs-cart.com/4.2.x/addons/api_extending.htm
i'm try extending Api using this link: but its not work .
step one : as in document i created a app/Tygh/Addons/Tygh/Api/Entities/Things.php
step 2: Write this code:
namespace Tygh\Api\Entities;
use Tygh\Api\AEntity;
use Tygh\Api\Response;
class Things extends AEntity
{
public function index($id = '', $params = array())
{
return array(
'status' => Response::STATUS_OK,
'data' => array('name' => 'vivek')
);
}
public function create($params)
{
return array(
'status' => Response::STATUS_CREATED,
'data' => array('name' => 'vivek_gupta')
);
}
public function update($id, $params)
{
return array(
'status' => Response::STATUS_OK,
'data' => array('name' => 'gupta')
);
}
public function delete($id)
{
return array(
'status' => Response::STATUS_NO_CONTENT,
);
}
}
?>
Step-3: calling with
try {
$Entity = "Things";
$Response = $cscartapi->get($Entity, $params);
print_r($Response);
} catch (Exception $e) {
print $e->getMessage();
}
Please help me , how we can extend Api with custom entities.