Fix PHPCS

This commit is contained in:
jfefe 2015-05-06 00:55:42 +02:00
parent 3b1f6e8a5a
commit dbb9449ee7
9 changed files with 187 additions and 155 deletions

View File

@ -19,7 +19,6 @@
/** /**
*
* API class for skeleton object * API class for skeleton object
* *
* @smart-auto-routing false * @smart-auto-routing false
@ -28,10 +27,9 @@
* *
* *
*/ */
class SkeletonApi extends DolibarrApi { class SkeletonApi extends DolibarrApi
{
/** /**
*
* @var array $FIELDS Mandatory fields, checked when create and update object * @var array $FIELDS Mandatory fields, checked when create and update object
*/ */
static $FIELDS = array( static $FIELDS = array(
@ -61,10 +59,10 @@ class SkeletonApi extends DolibarrApi {
* *
* Return an array with skeleton informations * Return an array with skeleton informations
* *
* @url GET skeleton/{id}
* @param int $id ID of skeleton * @param int $id ID of skeleton
* @return array|mixed data without useless information * @return array|mixed data without useless information
* *
* @url GET skeleton/{id}
* @throws RestException * @throws RestException
*/ */
function get($id) function get($id)
@ -90,8 +88,6 @@ class SkeletonApi extends DolibarrApi {
* *
* Get a list of skeletons * Get a list of skeletons
* *
* @url GET /skeletons/
*
* @param int $mode Use this param to filter list * @param int $mode Use this param to filter list
* @param string $sortfield Sort field * @param string $sortfield Sort field
* @param string $sortorder Sort order * @param string $sortorder Sort order
@ -99,6 +95,8 @@ class SkeletonApi extends DolibarrApi {
* @param int $page Page number * @param int $page Page number
* *
* @return array Array of skeleton objects * @return array Array of skeleton objects
*
* @url GET /skeletons/
*/ */
function getList($mode, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { function getList($mode, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) {
global $db, $conf; global $db, $conf;
@ -177,9 +175,10 @@ class SkeletonApi extends DolibarrApi {
/** /**
* Create skeleton object * Create skeleton object
* *
* @url POST skeleton/ * @param array $request_data Request datas
* @param array $request_data
* @return int ID of skeleton * @return int ID of skeleton
*
* @url POST skeleton/
*/ */
function post($request_data = NULL) function post($request_data = NULL)
{ {
@ -201,10 +200,11 @@ class SkeletonApi extends DolibarrApi {
/** /**
* Update skeleton * Update skeleton
* *
* @url PUT skeleton/{id}
* @param int $id Id of skeleton to update * @param int $id Id of skeleton to update
* @param array $request_data Datas * @param array $request_data Datas
* @return int * @return int
*
* @url PUT skeleton/{id}
*/ */
function put($id, $request_data = NULL) function put($id, $request_data = NULL)
{ {
@ -234,9 +234,10 @@ class SkeletonApi extends DolibarrApi {
/** /**
* Delete skeleton * Delete skeleton
* *
* @param int $id Skeleton ID
* @return array
*
* @url DELETE skeleton/{id} * @url DELETE skeleton/{id}
* @param int $id
* @return type
*/ */
function delete($id) function delete($id)
{ {
@ -268,8 +269,10 @@ class SkeletonApi extends DolibarrApi {
/** /**
* Validate fields before create or update object * Validate fields before create or update object
* @param array $data *
* @param array $data Data to validate
* @return array * @return array
*
* @throws RestException * @throws RestException
*/ */
function _validate($data) function _validate($data)

View File

@ -22,8 +22,10 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
/** /**
* Class for API * Class for API
*
*/ */
class DolibarrApi { class DolibarrApi
{
/** /**
* @var DoliDb $db Database object * @var DoliDb $db Database object
@ -38,7 +40,7 @@ class DolibarrApi {
/** /**
* Constructor * Constructor
* *
* @var DoliDB $db Database handler * @param DoliDb $db Database handler
*/ */
function __construct($db) { function __construct($db) {
$this->db = $db; $this->db = $db;
@ -49,6 +51,7 @@ class DolibarrApi {
* Executed method when API is called without parameter * Executed method when API is called without parameter
* *
* Display a short message an return a http code 200 * Display a short message an return a http code 200
*
* @return array * @return array
*/ */
function index() function index()
@ -64,13 +67,14 @@ class DolibarrApi {
/** /**
* Clean sensible object datas * Clean sensible object datas
* @var object $object Object to clean *
* @param object $object Object to clean
* @return array Array of cleaned object properties * @return array Array of cleaned object properties
* *
* @todo use an array for properties to clean * @todo use an array for properties to clean
* *
*/ */
protected function _cleanObjectDatas($object){ function _cleanObjectDatas($object) {
// Remove $db object property for object // Remove $db object property for object
unset($object->db); unset($object->db);
@ -130,9 +134,8 @@ class DolibarrApi {
* API init * API init
* *
*/ */
class DolibarrApiInit extends DolibarrApi { class DolibarrApiInit extends DolibarrApi
{
function __construct() { function __construct() {
global $db; global $db;
@ -143,11 +146,12 @@ class DolibarrApiInit extends DolibarrApi {
* Login * Login
* *
* Log user with username and password * Log user with username and password
* @todo : to finish!
* *
* @param string $login Username * @param string $login Username
* @param string $password User password * @param string $password User password
* @param int $entity User entity * @param int $entity User entity
* @return array Response status and user token
*
* @throws RestException * @throws RestException
*/ */
public function login($login, $password, $entity = 0) { public function login($login, $password, $entity = 0) {
@ -194,6 +198,8 @@ class DolibarrApiInit extends DolibarrApi {
} }
/** /**
* Get status (Dolibarr version)
*
* @access protected * @access protected
* @class DolibarrApiAccess {@requires admin} * @class DolibarrApiAccess {@requires admin}
*/ */
@ -205,6 +211,5 @@ class DolibarrApiInit extends DolibarrApi {
'dolibarr_version' => DOL_VERSION 'dolibarr_version' => DOL_VERSION
) )
); );
} }
} }

View File

@ -7,7 +7,7 @@ use Luracast\Restler\RestException;
/** /**
* Description of DolibarrApiAccess * Dolibarr API access class
* *
* @author jfefe * @author jfefe
*/ */
@ -97,6 +97,10 @@ class DolibarrApiAccess implements iAuthenticate
} }
/** /**
* Verify access
*
* @param array $m Properties of method
*
* @access private * @access private
*/ */
public static function verifyAccess(array $m) public static function verifyAccess(array $m)

View File

@ -20,7 +20,6 @@
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
/** /**
*
* API class for category object * API class for category object
* *
* @smart-auto-routing false * @smart-auto-routing false
@ -29,10 +28,9 @@
* *
* *
*/ */
class CategoryApi extends DolibarrApi { class CategoryApi extends DolibarrApi
{
/** /**
*
* @var array $FIELDS Mandatory fields, checked when create and update object * @var array $FIELDS Mandatory fields, checked when create and update object
*/ */
static $FIELDS = array( static $FIELDS = array(
@ -72,11 +70,10 @@ class CategoryApi extends DolibarrApi {
* *
* Return an array with category informations * Return an array with category informations
* *
* @url GET category/{id}
*
* @param int $id ID of category * @param int $id ID of category
* @return array|mixed data without useless information * @return array|mixed data without useless information
* *
* @url GET category/{id}
* @throws RestException * @throws RestException
*/ */
function get($id) function get($id)
@ -102,15 +99,14 @@ class CategoryApi extends DolibarrApi {
* *
* Get a list of categories * Get a list of categories
* *
* @url GET /category/list
*
* @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact')
* @param string $sortfield Sort field * @param string $sortfield Sort field
* @param string $sortorder Sort order * @param string $sortorder Sort order
* @param int $limit Limit for list * @param int $limit Limit for list
* @param int $page Page number * @param int $page Page number
*
* @return array Array of category objects * @return array Array of category objects
*
* @url GET /category/list
*/ */
function getList($type='product', $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { function getList($type='product', $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) {
global $db, $conf; global $db, $conf;
@ -170,14 +166,13 @@ class CategoryApi extends DolibarrApi {
/** /**
* Get member categories list * Get member categories list
* *
* @url GET /category/list/member
*
* @param string $sortfield Sort field * @param string $sortfield Sort field
* @param string $sortorder Sort order * @param string $sortorder Sort order
* @param int $limit Limit for list * @param int $limit Limit for list
* @param int $page Page number * @param int $page Page number
*
* @return mixed * @return mixed
*
* @url GET /category/list/member
*/ */
function getListCategoryMember($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { function getListCategoryMember($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) {
return $this->getList('member', $sortfield, $sortorder, $limit, $page); return $this->getList('member', $sortfield, $sortorder, $limit, $page);
@ -186,14 +181,14 @@ class CategoryApi extends DolibarrApi {
/** /**
* Get customer categories list * Get customer categories list
* *
* @url GET /category/list/customer
*
* @param string $sortfield Sort field * @param string $sortfield Sort field
* @param string $sortorder Sort order * @param string $sortorder Sort order
* @param int $limit Limit for list * @param int $limit Limit for list
* @param int $page Page number * @param int $page Page number
* *
* @return mixed * @return mixed
*
* @url GET /category/list/customer
*/ */
function getListCategoryCustomer($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { function getListCategoryCustomer($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) {
return $this->getList('customer', $sortfield, $sortorder, $limit, $page); return $this->getList('customer', $sortfield, $sortorder, $limit, $page);
@ -202,14 +197,14 @@ class CategoryApi extends DolibarrApi {
/** /**
* Get supplier categories list * Get supplier categories list
* *
* @url GET /category/list/supplier
*
* @param string $sortfield Sort field * @param string $sortfield Sort field
* @param string $sortorder Sort order * @param string $sortorder Sort order
* @param int $limit Limit for list * @param int $limit Limit for list
* @param int $page Page number * @param int $page Page number
* *
* @return mixed * @return mixed
*
* @url GET /category/list/supplier
*/ */
function getListCategorySupplier($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { function getListCategorySupplier($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) {
return $this->getList('supplier', $sortfield, $sortorder, $limit, $page); return $this->getList('supplier', $sortfield, $sortorder, $limit, $page);
@ -218,14 +213,14 @@ class CategoryApi extends DolibarrApi {
/** /**
* Get product categories list * Get product categories list
* *
* @url GET /category/list/product
*
* @param string $sortfield Sort field * @param string $sortfield Sort field
* @param string $sortorder Sort order * @param string $sortorder Sort order
* @param int $limit Limit for list * @param int $limit Limit for list
* @param int $page Page number * @param int $page Page number
* *
* @return mixed * @return mixed
*
* @url GET /category/list/product
*/ */
function getListCategoryProduct($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { function getListCategoryProduct($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) {
return $this->getList('product', $sortfield, $sortorder, $limit, $page); return $this->getList('product', $sortfield, $sortorder, $limit, $page);
@ -234,9 +229,13 @@ class CategoryApi extends DolibarrApi {
/** /**
* Get contact categories list * Get contact categories list
* *
* @url GET /category/list/contact * @param string $sortfield Sort field
* * @param string $sortorder Sort order
* @param int $limit Limit for list
* @param int $page Page number
* @return mixed * @return mixed
*
* @url GET /category/list/contact
*/ */
function getListCategoryContact($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { function getListCategoryContact($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) {
return $this->getList('contact', $sortfield, $sortorder, $limit, $page); return $this->getList('contact', $sortfield, $sortorder, $limit, $page);
@ -245,9 +244,10 @@ class CategoryApi extends DolibarrApi {
/** /**
* Create category object * Create category object
* *
* @url POST category/ * @param array $request_data Request data
* @param array $request_data
* @return int ID of category * @return int ID of category
*
* @url POST category/
*/ */
function post($request_data = NULL) function post($request_data = NULL)
{ {
@ -269,10 +269,11 @@ class CategoryApi extends DolibarrApi {
/** /**
* Update category * Update category
* *
* @url PUT category/{id}
* @param int $id Id of category to update * @param int $id Id of category to update
* @param array $request_data Datas * @param array $request_data Datas
* @return int * @return int
*
* @url PUT category/{id}
*/ */
function put($id, $request_data = NULL) function put($id, $request_data = NULL)
{ {
@ -302,9 +303,10 @@ class CategoryApi extends DolibarrApi {
/** /**
* Delete category * Delete category
* *
* @param int $id Category ID
* @return array
*
* @url DELETE category/{id} * @url DELETE category/{id}
* @param int $id
* @return type
*/ */
function delete($id) function delete($id)
{ {
@ -334,8 +336,10 @@ class CategoryApi extends DolibarrApi {
/** /**
* Validate fields before create or update object * Validate fields before create or update object
* @param array $data *
* @param array $data Data to validate
* @return array * @return array
*
* @throws RestException * @throws RestException
*/ */
function _validate($data) function _validate($data)

View File

@ -20,19 +20,22 @@
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
/** /**
*
* API class for commande object * API class for commande object
* *
* @smart-auto-routing false * @smart-auto-routing false
* @access protected * @access protected
* @class DolibarrApiAccess {@requires user,external} * @class DolibarrApiAccess {@requires user,external}
* *
* @category Api
* @package Api
* @author jfefe
*
* *
*/ */
class CommandeApi extends DolibarrApi { class CommandeApi extends DolibarrApi
{
/** /**
*
* @var array $FIELDS Mandatory fields, checked when create and update object * @var array $FIELDS Mandatory fields, checked when create and update object
*/ */
static $FIELDS = array( static $FIELDS = array(
@ -62,13 +65,13 @@ class CommandeApi extends DolibarrApi {
* *
* Return an array with commande informations * Return an array with commande informations
* *
* @url GET order/{id} * @param int $id ID of order
* @param int $id ID of order * @param string $ref Ref of object
* @param string $ref Ref of object
* @param string $ref_ext External reference of object * @param string $ref_ext External reference of object
* @param string $ref_int Internal reference of other object * @param string $ref_int Internal reference of other object
* @return array|mixed data without useless information * @return array|mixed data without useless information
* *
* @url GET order/{id}
* @throws RestException * @throws RestException
*/ */
function get($id='',$ref='', $ref_ext='', $ref_int='') function get($id='',$ref='', $ref_ext='', $ref_int='')
@ -95,15 +98,14 @@ class CommandeApi extends DolibarrApi {
* *
* Get a list of orders * Get a list of orders
* *
* @url GET /order/list
*
* @param int $mode Use this param to filter list * @param int $mode Use this param to filter list
* @param string $sortfield Sort field * @param string $sortfield Sort field
* @param string $sortorder Sort order * @param string $sortorder Sort order
* @param int $limit Limit for list * @param int $limit Limit for list
* @param int $page Page number * @param int $page Page number
* *
* @return array Array of order objects * @url GET /order/list
* @return array Array of order objects
*/ */
function getList($mode=0, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { function getList($mode=0, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) {
global $db, $conf; global $db, $conf;
@ -181,9 +183,11 @@ class CommandeApi extends DolibarrApi {
/** /**
* Create order object * Create order object
* *
* @url POST order/ * @param array $request_data Request datas
* @param array $request_data *
* @return int ID of commande * @url POST order/
*
* @return int ID of commande
*/ */
function post($request_data = NULL) function post($request_data = NULL)
{ {
@ -206,9 +210,11 @@ class CommandeApi extends DolibarrApi {
/** /**
* Update order * Update order
* *
* @url PUT order/{id}
* @param int $id Id of commande to update * @param int $id Id of commande to update
* @param array $request_data Datas * @param array $request_data Datas
*
* @url PUT order/{id}
*
* @return int * @return int
*/ */
function put($id, $request_data = NULL) function put($id, $request_data = NULL)
@ -237,11 +243,13 @@ class CommandeApi extends DolibarrApi {
} }
/** /**
* Delete commande * Delete order
* *
* @url DELETE order/{id} * @param int $id Order ID
* @param int $id *
* @return type * @url DELETE order/{id}
*
* @return array
*/ */
function delete($id) function delete($id)
{ {
@ -273,11 +281,14 @@ class CommandeApi extends DolibarrApi {
/** /**
* Validate an order * Validate an order
* *
* @param int $id Order ID
* @param int $idwarehouse Warehouse ID
*
* @url GET order/{id}/validate * @url GET order/{id}/validate
* @url POST order/{id}/validate * @url POST order/{id}/validate
* *
* @param int $id Order ID * @return array
* @param int $warehouse Warehouse ID *
*/ */
function validOrder($id, $idwarehouse=0) function validOrder($id, $idwarehouse=0)
{ {
@ -307,9 +318,10 @@ class CommandeApi extends DolibarrApi {
/** /**
* Validate fields before create or update object * Validate fields before create or update object
* @param array $data *
* @return array * @param array $data Array with data to verify
* @throws RestException * @return array
* @throws RestException
*/ */
function _validate($data) function _validate($data)
{ {

View File

@ -20,17 +20,15 @@
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
/** /**
*
* API class for invoice object * API class for invoice object
* *
* @smart-auto-routing false * @smart-auto-routing false
* @access protected * @access protected
* @class DolibarrApiAccess {@requires user,external} * @class DolibarrApiAccess {@requires user,external}
* *
*
*/ */
class InvoiceApi extends DolibarrApi { class InvoiceApi extends DolibarrApi
{
/** /**
* *
* @var array $FIELDS Mandatory fields, checked when create and update object * @var array $FIELDS Mandatory fields, checked when create and update object
@ -62,10 +60,10 @@ class InvoiceApi extends DolibarrApi {
* *
* Return an array with invoice informations * Return an array with invoice informations
* *
* @url GET invoice/{id}
* @param int $id ID of invoice * @param int $id ID of invoice
* @return array|mixed data without useless information * @return array|mixed data without useless information
* *
* @url GET invoice/{id}
* @throws RestException * @throws RestException
*/ */
function get($id) function get($id)
@ -91,11 +89,6 @@ class InvoiceApi extends DolibarrApi {
* *
* Get a list of invoices * Get a list of invoices
* *
* @url GET invoice/list
* @url GET invoice/list/{mode}
* @url GET thirdparty/{socid}/invoice/list
* @url GET thirdparty/{socid}/invoice/list/{mode}
*
* @param int $socid Filter list with thirdparty ID * @param int $socid Filter list with thirdparty ID
* @param string $mode Filter by invoice status : draft | unpaid | paid | cancelled * @param string $mode Filter by invoice status : draft | unpaid | paid | cancelled
* @param string $sortfield Sort field * @param string $sortfield Sort field
@ -104,6 +97,11 @@ class InvoiceApi extends DolibarrApi {
* @param int $page Page number * @param int $page Page number
* *
* @return array Array of invoice objects * @return array Array of invoice objects
*
* @url GET invoice/list
* @url GET invoice/list/{mode}
* @url GET thirdparty/{socid}/invoice/list
* @url GET thirdparty/{socid}/invoice/list/{mode}
*/ */
function getList($socid=0, $mode='', $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { function getList($socid=0, $mode='', $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) {
global $db, $conf; global $db, $conf;
@ -183,11 +181,10 @@ class InvoiceApi extends DolibarrApi {
/** /**
* Create invoice object * Create invoice object
* *
* @url POST invoice/ * @param array $request_data Request datas
*
* @param array $request_data
*
* @return int ID of invoice * @return int ID of invoice
*
* @url POST invoice/
*/ */
function post($request_data = NULL) function post($request_data = NULL)
{ {
@ -212,10 +209,11 @@ class InvoiceApi extends DolibarrApi {
/** /**
* Update invoice * Update invoice
* *
* @url PUT invoice/{id}
* @param int $id Id of invoice to update * @param int $id Id of invoice to update
* @param array $request_data Datas * @param array $request_data Datas
* @return int * @return int
*
* @url PUT invoice/{id}
*/ */
function put($id, $request_data = NULL) function put($id, $request_data = NULL)
{ {
@ -245,9 +243,10 @@ class InvoiceApi extends DolibarrApi {
/** /**
* Delete invoice * Delete invoice
* *
* @url DELETE invoice/{id} * @param int $id Invoice ID
* @param int $id
* @return type * @return type
*
* @url DELETE invoice/{id}
*/ */
function delete($id) function delete($id)
{ {
@ -279,8 +278,10 @@ class InvoiceApi extends DolibarrApi {
/** /**
* Validate fields before create or update object * Validate fields before create or update object
* @param array $data *
* @param array $data Datas to validate
* @return array * @return array
*
* @throws RestException * @throws RestException
*/ */
function _validate($data) function _validate($data)

View File

@ -20,19 +20,16 @@
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
/** /**
*
* API class for product object * API class for product object
* *
* @smart-auto-routing false * @smart-auto-routing false
* @access protected * @access protected
* @class DolibarrApiAccess {@requires user,external} * @class DolibarrApiAccess {@requires user,external}
* *
*
*/ */
class ProductApi extends DolibarrApi { class ProductApi extends DolibarrApi
{
/** /**
*
* @var array $FIELDS Mandatory fields, checked when create and update object * @var array $FIELDS Mandatory fields, checked when create and update object
*/ */
static $FIELDS = array( static $FIELDS = array(
@ -63,10 +60,12 @@ class ProductApi extends DolibarrApi {
* *
* Return an array with product informations * Return an array with product informations
* *
* @url GET product/{id} * @param int $id ID of product
* @param int $id ID of product * @param string $ref Product ref
* @param string $ref_ext Product ref ext
* @return array|mixed data without useless information * @return array|mixed data without useless information
* *
* @url GET product/{id}
* @throws RestException * @throws RestException
*/ */
function get($id='', $ref='', $ref_ext='') function get($id='', $ref='', $ref_ext='')
@ -94,8 +93,6 @@ class ProductApi extends DolibarrApi {
* *
* Get a list of products * Get a list of products
* *
* @url GET /product/list
*
* @param int $mode Use this param to filter list (0 for all, 1 for only product, 2 for only service) * @param int $mode Use this param to filter list (0 for all, 1 for only product, 2 for only service)
* @param mixed $to_sell Filter products to sell (1) or not to sell (0) * @param mixed $to_sell Filter products to sell (1) or not to sell (0)
* @param mixed $to_buy Filter products to nuy (1) or not to buy (0) * @param mixed $to_buy Filter products to nuy (1) or not to buy (0)
@ -105,6 +102,8 @@ class ProductApi extends DolibarrApi {
* @param int $page Page number * @param int $page Page number
* *
* @return array Array of product objects * @return array Array of product objects
*
* @url GET /product/list
*/ */
function getList($mode=0, $to_sell='', $to_buy='', $sortfield = "p.ref", $sortorder = 'ASC', $limit = 0, $page = 0) { function getList($mode=0, $to_sell='', $to_buy='', $sortfield = "p.ref", $sortorder = 'ASC', $limit = 0, $page = 0) {
global $db, $conf; global $db, $conf;
@ -170,10 +169,10 @@ class ProductApi extends DolibarrApi {
/** /**
* Create product object * Create product object
* *
* @url POST product/ * @param array $request_data Request data
*
* @param array $request_data
* @return int ID of product * @return int ID of product
*
* @url POST product/
*/ */
function post($request_data = NULL) function post($request_data = NULL)
{ {
@ -198,11 +197,11 @@ class ProductApi extends DolibarrApi {
/** /**
* Update product * Update product
* *
* @url PUT product/{id}
*
* @param int $id Id of product to update * @param int $id Id of product to update
* @param array $request_data Datas * @param array $request_data Datas
* @return int * @return int
*
* @url PUT product/{id}
*/ */
function put($id, $request_data = NULL) function put($id, $request_data = NULL)
{ {
@ -232,9 +231,10 @@ class ProductApi extends DolibarrApi {
/** /**
* Delete product * Delete product
* *
* @param int $id Product ID
* @return array
*
* @url DELETE product/{id} * @url DELETE product/{id}
* @param int $id
* @return type
*/ */
function delete($id) function delete($id)
{ {
@ -255,7 +255,8 @@ class ProductApi extends DolibarrApi {
/** /**
* Validate fields before create or update object * Validate fields before create or update object
* @param array $data *
* @param array $data Datas to validate
* @return array * @return array
* @throws RestException * @throws RestException
*/ */

View File

@ -20,18 +20,15 @@ use Luracast\Restler\RestException;
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
/** /**
*
* API class for contact object * API class for contact object
* *
* @smart-auto-routing false * @smart-auto-routing false
* @access protected * @access protected
* @class DolibarrApiAccess {@requires user,external} * @class DolibarrApiAccess {@requires user,external}
* *
*
*/ */
class ContactApi extends DolibarrApi class ContactApi extends DolibarrApi
{ {
/** /**
* *
* @var array $FIELDS Mandatory fields, checked when create and update object * @var array $FIELDS Mandatory fields, checked when create and update object
@ -62,10 +59,10 @@ class ContactApi extends DolibarrApi
* *
* Return an array with contact informations * Return an array with contact informations
* *
* @url GET contact/{id}
* @param int $id ID of contact * @param int $id ID of contact
* @return array|mixed data without useless information * @return array|mixed data without useless information
* *
* @url GET contact/{id}
* @throws RestException * @throws RestException
*/ */
function get($id) { function get($id) {
@ -93,19 +90,18 @@ class ContactApi extends DolibarrApi
* *
* Get a list of contacts * Get a list of contacts
* *
* @url GET /contact/list
* @url GET /contact/list/{socid}
* @url GET /thirdparty/{socid}/contacts
*
*
* @param int $socid ID of thirdparty to filter list * @param int $socid ID of thirdparty to filter list
* @param string $sortfield Sort field * @param string $sortfield Sort field
* @param string $sortorder Sort order * @param string $sortorder Sort order
* @param int $limit Limit for list * @param int $limit Limit for list
* @param int $page Page number * @param int $page Page number
* @throws RestException
*
* @return array Array of contact objects * @return array Array of contact objects
*
* @url GET /contact/list
* @url GET /contact/list/{socid}
* @url GET /thirdparty/{socid}/contacts
*
* @throws RestException
*/ */
function getList($socid = 0, $sortfield = "c.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { function getList($socid = 0, $sortfield = "c.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) {
global $db, $conf; global $db, $conf;
@ -192,9 +188,10 @@ class ContactApi extends DolibarrApi
/** /**
* Create contact object * Create contact object
* *
* @param array $request_data Request datas
* @return int ID of contact
*
* @url POST contact/ * @url POST contact/
* @param array $request_data
* @return int ID of contact
*/ */
function post($request_data = NULL) { function post($request_data = NULL) {
if (!DolibarrApiAccess::$user->rights->societe->contact->creer) if (!DolibarrApiAccess::$user->rights->societe->contact->creer)
@ -214,10 +211,11 @@ class ContactApi extends DolibarrApi
/** /**
* Update contact * Update contact
* *
* @url PUT contact/{id}
* @param int $id Id of contact to update * @param int $id Id of contact to update
* @param array $request_data Datas * @param array $request_data Datas
* @return int * @return int
*
* @url PUT contact/{id}
*/ */
function put($id, $request_data = NULL) { function put($id, $request_data = NULL) {
if (!DolibarrApiAccess::$user->rights->societe->contact->creer) if (!DolibarrApiAccess::$user->rights->societe->contact->creer)
@ -250,9 +248,10 @@ class ContactApi extends DolibarrApi
/** /**
* Delete contact * Delete contact
* *
* @param int $id Contact ID
* @return array
*
* @url DELETE contact/{id} * @url DELETE contact/{id}
* @param int $id
* @return type
*/ */
function delete($id) { function delete($id) {
if (!DolibarrApiAccess::$user->rights->contact->supprimer) if (!DolibarrApiAccess::$user->rights->contact->supprimer)
@ -275,8 +274,9 @@ class ContactApi extends DolibarrApi
/** /**
* Validate fields before create or update object * Validate fields before create or update object
* @param array $data *
* @return array * @param array $data Data to validate
* @return array
* @throws RestException * @throws RestException
*/ */
function _validate($data) { function _validate($data) {

View File

@ -19,17 +19,15 @@
/** /**
*
* API class for thirdparty object * API class for thirdparty object
* *
* @smart-auto-routing false * @smart-auto-routing false
* @access protected * @access protected
* @class DolibarrApiAccess {@requires user,external} * @class DolibarrApiAccess {@requires user,external}
* *
*
*/ */
class ThirdpartyApi extends DolibarrApi { class ThirdpartyApi extends DolibarrApi
{
/** /**
* *
* @var array $FIELDS Mandatory fields, checked when create and update object * @var array $FIELDS Mandatory fields, checked when create and update object
@ -65,10 +63,10 @@ class ThirdpartyApi extends DolibarrApi {
* *
* Return an array with thirdparty informations * Return an array with thirdparty informations
* *
* @url GET thirdparty/{id}
* @param int $id ID of thirdparty * @param int $id ID of thirdparty
* @return array|mixed data without useless information * @return array|mixed data without useless information
* *
* @url GET thirdparty/{id}
* @throws RestException * @throws RestException
*/ */
function get($id) function get($id)
@ -94,8 +92,6 @@ class ThirdpartyApi extends DolibarrApi {
* *
* Get a list of thirdparties * Get a list of thirdparties
* *
* @url GET /thirdparty/list
*
* @param int $mode Set to 1 to show only customers * @param int $mode Set to 1 to show only customers
* Set to 2 to show only prospects * Set to 2 to show only prospects
* Set to 3 to show only those are not customer neither prospect * Set to 3 to show only those are not customer neither prospect
@ -103,9 +99,10 @@ class ThirdpartyApi extends DolibarrApi {
* @param string $sortorder Sort order * @param string $sortorder Sort order
* @param int $limit Limit for list * @param int $limit Limit for list
* @param int $page Page number * @param int $page Page number
*
*
* @return array Array of thirdparty objects * @return array Array of thirdparty objects
*
* @url GET /thirdparty/list
*
*/ */
function getList($mode=0, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { function getList($mode=0, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) {
global $db, $conf; global $db, $conf;
@ -183,9 +180,9 @@ class ThirdpartyApi extends DolibarrApi {
/** /**
* Show customers * Show customers
* *
* @url GET /thirdparty/list/customers
*
* @return array List of customers * @return array List of customers
*
* @url GET /thirdparty/list/customers
*/ */
function getListCustomers() { function getListCustomers() {
return $this->getList(1); return $this->getList(1);
@ -194,9 +191,9 @@ class ThirdpartyApi extends DolibarrApi {
/** /**
* Show prospects * Show prospects
* *
* @url GET /thirdparty/list/prospects
*
* @return array List of prospects * @return array List of prospects
*
* @url GET /thirdparty/list/prospects
*/ */
function getListProspects() { function getListProspects() {
return $this->getList('',1); return $this->getList('',1);
@ -205,9 +202,9 @@ class ThirdpartyApi extends DolibarrApi {
/** /**
* Show other * Show other
* *
* @url GET /thirdparty/list/others
*
* @return array List of thirpdparties who are not customer neither prospect * @return array List of thirpdparties who are not customer neither prospect
*
* @url GET /thirdparty/list/others
*/ */
function getListOthers() { function getListOthers() {
return $this->getList('','',1); return $this->getList('','',1);
@ -216,9 +213,10 @@ class ThirdpartyApi extends DolibarrApi {
/** /**
* Create thirdparty object * Create thirdparty object
* *
* @url POST thirdparty/ * @param array $request_data Request datas
* @param array $request_data
* @return int ID of thirdparty * @return int ID of thirdparty
*
* @url POST thirdparty/
*/ */
function post($request_data = NULL) function post($request_data = NULL)
{ {
@ -237,10 +235,11 @@ class ThirdpartyApi extends DolibarrApi {
/** /**
* Update thirdparty * Update thirdparty
* *
* @url PUT thirdparty/{id}
* @param int $id Id of thirdparty to update * @param int $id Id of thirdparty to update
* @param array $request_data Datas * @param array $request_data Datas
* @return int * @return int
*
* @url PUT thirdparty/{id}
*/ */
function put($id, $request_data = NULL) function put($id, $request_data = NULL)
{ {
@ -270,9 +269,10 @@ class ThirdpartyApi extends DolibarrApi {
/** /**
* Delete thirdparty * Delete thirdparty
* *
* @url DELETE thirdparty/{id} * @param int $id Thirparty ID
* @param int $id
* @return type * @return type
*
* @url DELETE thirdparty/{id}
*/ */
function delete($id) function delete($id)
{ {
@ -293,8 +293,10 @@ class ThirdpartyApi extends DolibarrApi {
/** /**
* Validate fields before create or update object * Validate fields before create or update object
* @param array $data *
* @param array $data Datas to validate
* @return array * @return array
*
* @throws RestException * @throws RestException
*/ */
function _validate($data) function _validate($data)