mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
api fixes
According to [RFC2616](https://www.rfc-editor.org/rfc/rfc2616#section-10.2), APIs should return 2xx status codes if the request was correct. The response should be status 200 with an empty result array.
This commit is contained in:
parent
aa43e18d56
commit
b78632a20e
|
|
@ -540,10 +540,6 @@ class Members extends DolibarrApi
|
|||
|
||||
$result = $categories->getListForItem($id, 'member', $sortfield, $sortorder, $limit, $page);
|
||||
|
||||
if (empty($result)) {
|
||||
throw new RestException(404, 'No category found');
|
||||
}
|
||||
|
||||
if ($result < 0) {
|
||||
throw new RestException(503, 'Error when retrieve category list : '.$categories->error);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,9 +136,6 @@ class MembersTypes extends DolibarrApi
|
|||
} else {
|
||||
throw new RestException(503, 'Error when retrieve member type list : '.$this->db->lasterror());
|
||||
}
|
||||
if (!count($obj_ret)) {
|
||||
throw new RestException(404, 'No member type found');
|
||||
}
|
||||
|
||||
return $obj_ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,9 +133,6 @@ class Subscriptions extends DolibarrApi
|
|||
} else {
|
||||
throw new RestException(503, 'Error when retrieve subscription list : '.$this->db->lasterror());
|
||||
}
|
||||
if (!count($obj_ret)) {
|
||||
throw new RestException(404, 'No Subscription found');
|
||||
}
|
||||
|
||||
return $obj_ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1156,10 +1156,6 @@ class Setup extends DolibarrApi
|
|||
throw new RestException(503, 'Error when retrieving list of extra fields : '.$this->db->lasterror());
|
||||
}
|
||||
|
||||
if (!count($list)) {
|
||||
throw new RestException(404, 'No extrafield found');
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -182,9 +182,7 @@ class Boms extends DolibarrApi
|
|||
} else {
|
||||
throw new RestException(503, 'Error when retrieve bom list');
|
||||
}
|
||||
if (!count($obj_ret)) {
|
||||
throw new RestException(404, 'No bom found');
|
||||
}
|
||||
|
||||
return $obj_ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -182,9 +182,7 @@ class Categories extends DolibarrApi
|
|||
} else {
|
||||
throw new RestException(503, 'Error when retrieve category list : '.$this->db->lasterror());
|
||||
}
|
||||
if (!count($obj_ret)) {
|
||||
throw new RestException(404, 'No category found');
|
||||
}
|
||||
|
||||
return $obj_ret;
|
||||
}
|
||||
|
||||
|
|
@ -342,9 +340,6 @@ class Categories extends DolibarrApi
|
|||
$categories = $this->category->getListForItem($id, $type, $sortfield, $sortorder, $limit, $page);
|
||||
|
||||
if (!is_array($categories)) {
|
||||
if ($categories == 0) {
|
||||
throw new RestException(404, 'No category found for this object');
|
||||
}
|
||||
throw new RestException(600, 'Error when fetching object categories', array_merge(array($this->category->error), $this->category->errors));
|
||||
}
|
||||
return $categories;
|
||||
|
|
|
|||
|
|
@ -192,9 +192,7 @@ class AgendaEvents extends DolibarrApi
|
|||
} else {
|
||||
throw new RestException(503, 'Error when retrieve Agenda Event list : '.$this->db->lasterror());
|
||||
}
|
||||
if (!count($obj_ret)) {
|
||||
throw new RestException(404, 'No Agenda Event found');
|
||||
}
|
||||
|
||||
return $obj_ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -245,9 +245,7 @@ class Proposals extends DolibarrApi
|
|||
} else {
|
||||
throw new RestException(503, 'Error when retrieve propal list : '.$this->db->lasterror());
|
||||
}
|
||||
if (!count($obj_ret)) {
|
||||
throw new RestException(404, 'No proposal found');
|
||||
}
|
||||
|
||||
return $obj_ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -259,9 +259,7 @@ class Orders extends DolibarrApi
|
|||
} else {
|
||||
throw new RestException(503, 'Error when retrieve commande list : '.$this->db->lasterror());
|
||||
}
|
||||
if (!count($obj_ret)) {
|
||||
throw new RestException(404, 'No order found');
|
||||
}
|
||||
|
||||
return $obj_ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -281,9 +281,7 @@ class Invoices extends DolibarrApi
|
|||
} else {
|
||||
throw new RestException(503, 'Error when retrieve invoice list : '.$this->db->lasterror());
|
||||
}
|
||||
if (!count($obj_ret)) {
|
||||
throw new RestException(404, 'No invoice found');
|
||||
}
|
||||
|
||||
return $obj_ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -181,9 +181,7 @@ class Contracts extends DolibarrApi
|
|||
} else {
|
||||
throw new RestException(503, 'Error when retrieve contrat list : '.$this->db->lasterror());
|
||||
}
|
||||
if (!count($obj_ret)) {
|
||||
throw new RestException(404, 'No contract found');
|
||||
}
|
||||
|
||||
return $obj_ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -165,9 +165,6 @@ class Donations extends DolibarrApi
|
|||
} else {
|
||||
throw new RestException(503, 'Error when retrieve donation list : '.$this->db->lasterror());
|
||||
}
|
||||
if (!count($obj_ret)) {
|
||||
throw new RestException(404, 'No donation found');
|
||||
}
|
||||
|
||||
return $obj_ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -151,9 +151,7 @@ class ExpenseReports extends DolibarrApi
|
|||
} else {
|
||||
throw new RestException(503, 'Error when retrieve Expense Report list : '.$this->db->lasterror());
|
||||
}
|
||||
if (!count($obj_ret)) {
|
||||
throw new RestException(404, 'No Expense Report found');
|
||||
}
|
||||
|
||||
return $obj_ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -190,9 +190,7 @@ class Interventions extends DolibarrApi
|
|||
} else {
|
||||
throw new RestException(503, 'Error when retrieve intervention list : '.$this->db->lasterror());
|
||||
}
|
||||
if (!count($obj_ret)) {
|
||||
throw new RestException(404, 'No intervention found');
|
||||
}
|
||||
|
||||
return $obj_ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -109,10 +109,6 @@ class KnowledgeManagement extends DolibarrApi
|
|||
|
||||
$result = $categories->getListForItem($id, 'knowledgemanagement', $sortfield, $sortorder, $limit, $page);
|
||||
|
||||
if (empty($result)) {
|
||||
throw new RestException(404, 'No category found');
|
||||
}
|
||||
|
||||
if ($result < 0) {
|
||||
throw new RestException(503, 'Error when retrieve category list : '.join(',', array_merge(array($categories->error), $categories->errors)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -190,9 +190,7 @@ class MyModuleApi extends DolibarrApi
|
|||
} else {
|
||||
throw new RestException(503, 'Error when retrieving myobject list: '.$this->db->lasterror());
|
||||
}
|
||||
if (!count($obj_ret)) {
|
||||
throw new RestException(404, 'No myobject found');
|
||||
}
|
||||
|
||||
return $obj_ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -180,9 +180,7 @@ class Mos extends DolibarrApi
|
|||
} else {
|
||||
throw new RestException(503, 'Error when retrieve MO list');
|
||||
}
|
||||
if (!count($obj_ret)) {
|
||||
throw new RestException(404, 'No MO found');
|
||||
}
|
||||
|
||||
return $obj_ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -187,9 +187,7 @@ class Partnerships extends DolibarrApi
|
|||
} else {
|
||||
throw new RestException(503, 'Error when retrieving partnership list: '.$this->db->lasterror());
|
||||
}
|
||||
if (!count($obj_ret)) {
|
||||
throw new RestException(404, 'No partnership found');
|
||||
}
|
||||
|
||||
return $obj_ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -277,9 +277,6 @@ class Products extends DolibarrApi
|
|||
} else {
|
||||
throw new RestException(503, 'Error when retrieve product list : '.$this->db->lasterror());
|
||||
}
|
||||
if (!count($obj_ret)) {
|
||||
throw new RestException(404, 'No product found');
|
||||
}
|
||||
|
||||
//if $pagination_data is true the response will contain element data with all values and element pagination with pagination data(total,page,limit)
|
||||
if ($pagination_data) {
|
||||
|
|
@ -601,10 +598,6 @@ class Products extends DolibarrApi
|
|||
|
||||
$result = $categories->getListForItem($id, 'product', $sortfield, $sortorder, $limit, $page);
|
||||
|
||||
if (empty($result)) {
|
||||
throw new RestException(404, 'No category found');
|
||||
}
|
||||
|
||||
if ($result < 0) {
|
||||
throw new RestException(503, 'Error when retrieve category list : '.join(',', array_merge(array($categories->error), $categories->errors)));
|
||||
}
|
||||
|
|
@ -953,9 +946,7 @@ class Products extends DolibarrApi
|
|||
} else {
|
||||
throw new RestException(503, 'Error when retrieve product list : '.$this->db->lasterror());
|
||||
}
|
||||
if (!count($obj_ret)) {
|
||||
throw new RestException(404, 'No product found');
|
||||
}
|
||||
|
||||
return $obj_ret;
|
||||
}
|
||||
|
||||
|
|
@ -1080,10 +1071,6 @@ class Products extends DolibarrApi
|
|||
$return[] = $this->_filterObjectProperties($this->_cleanObjectDatas($tmp), $properties);
|
||||
}
|
||||
|
||||
if (!count($return)) {
|
||||
throw new RestException(404, 'No product attribute found');
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
|
@ -1949,10 +1936,6 @@ class Products extends DolibarrApi
|
|||
}
|
||||
}
|
||||
|
||||
if (empty($stockData)) {
|
||||
throw new RestException(404, 'No stock found');
|
||||
}
|
||||
|
||||
return array('stock_warehouses'=>$stockData);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -144,9 +144,7 @@ class StockMovements extends DolibarrApi
|
|||
} else {
|
||||
throw new RestException(503, 'Error when retrieve stock movement list : '.$this->db->lasterror());
|
||||
}
|
||||
if (!count($obj_ret)) {
|
||||
throw new RestException(404, 'No stock movement found');
|
||||
}
|
||||
|
||||
return $obj_ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -150,9 +150,7 @@ class Warehouses extends DolibarrApi
|
|||
} else {
|
||||
throw new RestException(503, 'Error when retrieve warehouse list : '.$this->db->lasterror());
|
||||
}
|
||||
if (!count($obj_ret)) {
|
||||
throw new RestException(404, 'No warehouse found');
|
||||
}
|
||||
|
||||
return $obj_ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -226,9 +226,7 @@ class Recruitments extends DolibarrApi
|
|||
} else {
|
||||
throw new RestException(503, 'Error when retrieving jobposition list: '.$this->db->lasterror());
|
||||
}
|
||||
if (!count($obj_ret)) {
|
||||
throw new RestException(404, 'No jobposition found');
|
||||
}
|
||||
|
||||
return $obj_ret;
|
||||
}
|
||||
|
||||
|
|
@ -333,9 +331,7 @@ class Recruitments extends DolibarrApi
|
|||
} else {
|
||||
throw new RestException(503, 'Error when retrieving candidature list: '.$this->db->lasterror());
|
||||
}
|
||||
if (!count($obj_ret)) {
|
||||
throw new RestException(404, 'No candidature found');
|
||||
}
|
||||
|
||||
return $obj_ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -465,10 +465,6 @@ class Contacts extends DolibarrApi
|
|||
|
||||
$result = $categories->getListForItem($id, 'contact', $sortfield, $sortorder, $limit, $page);
|
||||
|
||||
if (empty($result)) {
|
||||
throw new RestException(404, 'No category found');
|
||||
}
|
||||
|
||||
if ($result < 0) {
|
||||
throw new RestException(503, 'Error when retrieve category list : '.$categories->error);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -285,9 +285,7 @@ class Tickets extends DolibarrApi
|
|||
} else {
|
||||
throw new RestException(503, 'Error when retrieve ticket list');
|
||||
}
|
||||
if (!count($obj_ret)) {
|
||||
throw new RestException(404, 'No ticket found');
|
||||
}
|
||||
|
||||
return $obj_ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -134,9 +134,7 @@ class Users extends DolibarrApi
|
|||
} else {
|
||||
throw new RestException(503, 'Error when retrieve User list : '.$this->db->lasterror());
|
||||
}
|
||||
if (!count($obj_ret)) {
|
||||
throw new RestException(404, 'No User found');
|
||||
}
|
||||
|
||||
return $obj_ret;
|
||||
}
|
||||
|
||||
|
|
@ -590,9 +588,7 @@ class Users extends DolibarrApi
|
|||
} else {
|
||||
throw new RestException(503, 'Error when retrieve Group list : '.$this->db->lasterror());
|
||||
}
|
||||
if (!count($obj_ret)) {
|
||||
throw new RestException(404, 'No Group found');
|
||||
}
|
||||
|
||||
return $obj_ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user