2
0
forked from Wavyzz/dolibarr

Standardize API

This commit is contained in:
Laurent Destailleur
2020-10-05 12:21:54 +02:00
parent cfc3c01815
commit ee40aeecce
2 changed files with 19 additions and 12 deletions

View File

@@ -507,9 +507,10 @@ class Proposals extends DolibarrApi
* Delete a contact type of given commercial proposal
*
* @param int $id Id of commercial proposal to update
* @param int $rowid Row key of the contact in the array contact_ids.
* @param int $contactid Row key of the contact in the array contact_ids.
* @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER).
*
* @url DELETE {id}/contact/{rowid}
* @url DELETE {id}/contact/{contactid}/{type}
*
* @return int
*
@@ -517,7 +518,7 @@ class Proposals extends DolibarrApi
* @throws RestException 404
* @throws RestException 500
*/
public function deleteContact($id, $rowid)
public function deleteContact($id, $contactid, $type)
{
if (!DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401);
@@ -533,13 +534,19 @@ class Proposals extends DolibarrApi
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->propal->delete_contact($rowid);
$contacts = $this->invoice->liste_contact();
if (!$result) {
throw new RestException(500, 'Error when deleted the contact');
}
foreach ($contacts as $contact) {
if ($contact['id'] == $contactid && $contact['code'] == $type) {
$result = $this->propal->delete_contact($contact['rowid']);
return $this->propal;
if (!$result) {
throw new RestException(500, 'Error when deleted the contact');
}
}
}
return $this->_cleanObjectDatas($this->propal);
}
/**

View File

@@ -476,10 +476,10 @@ class Invoices extends DolibarrApi
* Delete a contact type of given invoice
*
* @param int $id Id of invoice to update
* @param int $rowid Row key of the contact in the array contact_ids.
* @param int $contactid Row key of the contact in the array contact_ids.
* @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER).
*
* @url DELETE {id}/contact/{rowid}/{type}
* @url DELETE {id}/contact/{contactid}/{type}
*
* @return array
*
@@ -487,7 +487,7 @@ class Invoices extends DolibarrApi
* @throws RestException 404
* @throws RestException 500
*/
public function deleteContact($id, $rowid, $type)
public function deleteContact($id, $contactid, $type)
{
if (!DolibarrApiAccess::$user->rights->facture->creer) {
throw new RestException(401);
@@ -506,7 +506,7 @@ class Invoices extends DolibarrApi
$contacts = $this->invoice->liste_contact();
foreach ($contacts as $contact) {
if ($contact['id'] == $rowid && $contact['code'] == $type) {
if ($contact['id'] == $contactid && $contact['code'] == $type) {
$result = $this->invoice->delete_contact($contact['rowid']);
if (!$result) {