Standardize API
This commit is contained in:
parent
cfc3c01815
commit
ee40aeecce
@ -507,9 +507,10 @@ class Proposals extends DolibarrApi
|
|||||||
* Delete a contact type of given commercial proposal
|
* Delete a contact type of given commercial proposal
|
||||||
*
|
*
|
||||||
* @param int $id Id of commercial proposal to update
|
* @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
|
* @return int
|
||||||
*
|
*
|
||||||
@ -517,7 +518,7 @@ class Proposals extends DolibarrApi
|
|||||||
* @throws RestException 404
|
* @throws RestException 404
|
||||||
* @throws RestException 500
|
* @throws RestException 500
|
||||||
*/
|
*/
|
||||||
public function deleteContact($id, $rowid)
|
public function deleteContact($id, $contactid, $type)
|
||||||
{
|
{
|
||||||
if (!DolibarrApiAccess::$user->rights->propal->creer) {
|
if (!DolibarrApiAccess::$user->rights->propal->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
@ -533,13 +534,19 @@ class Proposals extends DolibarrApi
|
|||||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
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) {
|
foreach ($contacts as $contact) {
|
||||||
throw new RestException(500, 'Error when deleted the 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -476,10 +476,10 @@ class Invoices extends DolibarrApi
|
|||||||
* Delete a contact type of given invoice
|
* Delete a contact type of given invoice
|
||||||
*
|
*
|
||||||
* @param int $id Id of invoice to update
|
* @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).
|
* @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER).
|
||||||
*
|
*
|
||||||
* @url DELETE {id}/contact/{rowid}/{type}
|
* @url DELETE {id}/contact/{contactid}/{type}
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
@ -487,7 +487,7 @@ class Invoices extends DolibarrApi
|
|||||||
* @throws RestException 404
|
* @throws RestException 404
|
||||||
* @throws RestException 500
|
* @throws RestException 500
|
||||||
*/
|
*/
|
||||||
public function deleteContact($id, $rowid, $type)
|
public function deleteContact($id, $contactid, $type)
|
||||||
{
|
{
|
||||||
if (!DolibarrApiAccess::$user->rights->facture->creer) {
|
if (!DolibarrApiAccess::$user->rights->facture->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
@ -506,7 +506,7 @@ class Invoices extends DolibarrApi
|
|||||||
$contacts = $this->invoice->liste_contact();
|
$contacts = $this->invoice->liste_contact();
|
||||||
|
|
||||||
foreach ($contacts as $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']);
|
$result = $this->invoice->delete_contact($contact['rowid']);
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user