NEW fetch contact by email with REST API
This commit is contained in:
parent
11bf662c38
commit
206b1189c9
@ -97,6 +97,48 @@ class Contacts extends DolibarrApi
|
|||||||
|
|
||||||
return $this->_cleanObjectDatas($this->contact);
|
return $this->_cleanObjectDatas($this->contact);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get properties of a contact object by Email
|
||||||
|
*
|
||||||
|
* @param string $email Email of contact
|
||||||
|
* @param int $includecount Count and return also number of elements the contact is used as a link for
|
||||||
|
* @return array|mixed data without useless information
|
||||||
|
*
|
||||||
|
* @url GET email/{email}
|
||||||
|
*
|
||||||
|
* @throws RestException 401 Insufficient rights
|
||||||
|
* @throws RestException 404 User or group not found
|
||||||
|
*/
|
||||||
|
public function getByEmail($email, $includecount = 0)
|
||||||
|
{
|
||||||
|
if (!DolibarrApiAccess::$user->rights->societe->contact->lire)
|
||||||
|
{
|
||||||
|
throw new RestException(401, 'No permission to read contacts');
|
||||||
|
}
|
||||||
|
if (empty($email)) {
|
||||||
|
$result = $this->contact->initAsSpecimen();
|
||||||
|
} else {
|
||||||
|
$result = $this->contact->fetch('', '', '', $email);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$result)
|
||||||
|
{
|
||||||
|
throw new RestException(404, 'Contact not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe'))
|
||||||
|
{
|
||||||
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($includecount)
|
||||||
|
{
|
||||||
|
$this->contact->load_ref_elements();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->_cleanObjectDatas($this->contact);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List contacts
|
* List contacts
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user