mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-07 16:41:48 +01:00
NEW: Add an API endpoint to get properties of a single line of an order (#34045)
* feat: add api get line properties route * chore: indent with tabs * chore: preserve original spaces * chore: tabs instead of space * fix: return Object instead of array
This commit is contained in:
@@ -363,6 +363,41 @@ class Orders extends DolibarrApi
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get properties of a line of an order object by id
|
||||
*
|
||||
* @param int $id Id of order
|
||||
* @param int $lineid Id of line
|
||||
* @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
|
||||
*
|
||||
* @url GET {id}/lines/{lineid}
|
||||
*
|
||||
* @return Object
|
||||
*/
|
||||
public function getLine($id, $lineid, $properties = '')
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->hasRight('commande', 'lire')) {
|
||||
throw new RestException(403);
|
||||
}
|
||||
|
||||
$result = $this->commande->fetch($id);
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'Order not found');
|
||||
}
|
||||
|
||||
if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
|
||||
throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
$this->commande->fetch_lines();
|
||||
foreach ($this->commande->lines as $line) {
|
||||
if ($line->id == $lineid) {
|
||||
return $this->_filterObjectProperties($this->_cleanObjectDatas($line), $properties);
|
||||
}
|
||||
}
|
||||
throw new RestException(404, 'Line not found');
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a line to given order
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user