NEW GET lines of an invoice in the REST API
Adds the ability to get lines of an invoice using the REST API
This commit is contained in:
parent
4cd89abffc
commit
f985b1ede6
@ -276,6 +276,36 @@ class Invoices extends DolibarrApi
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get lines of an invoice
|
||||
*
|
||||
* @param int $id Id of invoice
|
||||
*
|
||||
* @url GET {id}/lines
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function getLines($id) {
|
||||
if(! DolibarrApiAccess::$user->rights->facture->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$result = $this->invoice->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Invoice not found');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
$this->invoice->getLinesArray();
|
||||
$result = array();
|
||||
foreach ($this->invoice->lines as $line) {
|
||||
array_push($result,$this->_cleanObjectDatas($line));
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate an order
|
||||
*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user