Merge branch 'develop'
This commit is contained in:
commit
c531b093c8
2 changed files with 14 additions and 6 deletions
|
|
@ -3,7 +3,7 @@
|
|||
"type": "library",
|
||||
"description": "LDC CRM Client V4",
|
||||
"license": "MIT",
|
||||
"version": "4.0.8",
|
||||
"version": "4.0.9",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jérémy Munsch",
|
||||
|
|
|
|||
|
|
@ -302,8 +302,7 @@ class WPCrm
|
|||
}
|
||||
|
||||
/**
|
||||
* Toggle the current user optin value
|
||||
* on the current user and the crm
|
||||
* Activate the current user
|
||||
*
|
||||
* @return boolean True if the operation succeeded.
|
||||
* @throws \LDC\LDCCRM\Exceptions\ValidationException If a customer's hashcode could not be validated.
|
||||
|
|
@ -320,10 +319,19 @@ class WPCrm
|
|||
if ($customer->status) {
|
||||
return true;
|
||||
}
|
||||
if (!self::makeApiV4Call($customer, 'activate')) {
|
||||
return false;
|
||||
try {
|
||||
if (!self::makeApiV4Call($customer, 'activate')) {
|
||||
return false;
|
||||
}
|
||||
} catch (ApiErrorException $e) {
|
||||
switch ($e->getApiError()) {
|
||||
case ApiError::authorizationException->value():
|
||||
case ApiError::modelNotFound->value():
|
||||
return false;
|
||||
default:
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
$customer->opt_in = !$customer->opt_in;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue