Merge branch 'segmentation_optins' into 'develop'

chore: 🔖 release v4.1.0

See merge request ldc-web/projets/crm-client!8
This commit is contained in:
Vincent BRIDIER 2025-07-25 12:43:50 +00:00
commit 073725a56f
2 changed files with 19 additions and 10 deletions

View file

@ -3,7 +3,7 @@
"type": "library",
"description": "LDC CRM Client V4",
"license": "MIT",
"version": "4.0.9",
"version": "4.1.0",
"authors": [
{
"name": "Jérémy Munsch",

View file

@ -27,26 +27,35 @@ abstract class SingleOptin extends ClientModel
];
/**
* Set the single opt in status for an email
* Set the single opt in status for an email,
* with an optionnal answer associated.
*
* @param string $email
* @param boolean $opt_in
* @param string $email
* @param boolean $opt_in
* @param array<int,int>|null $answerId
* @return boolean true if succeeded
* @throws \LDC\LDCCRM\Exceptions\ValidationException If a field email could not be validated.
* @throws \LDC\LDCCRM\Exceptions\CrmException If an error occurs on server side or on getting response.
* @throws \LDC\LDCCRM\Exceptions\ApiErrorException If any error or \LDC\LDCCRM\Enums\ApiError occurs.
* Possibles are : - singleOptinCustomerExists, If a customer exists with this email.
*/
public static function setStatus(#[\SensitiveParameter] string $email, bool $opt_in): bool
public static function setStatus(#[\SensitiveParameter] string $email, bool $opt_in, ?array $answerId = null): bool
{
self::validateValue('email', $email);
static::setUpApiInterface();
$request = Utils::getResquest('apiV4.optin', [], [
'email' => $email,
'opt_in' => $opt_in
]);
$response = static::$apiInterface->call($request);
$payload = [
'email' => $email,
'opt_in' => $opt_in,
];
if (!is_null($answerId) && count($answerId)) {
$payload['answer_id'] = $answerId;
}
$response = static::$apiInterface->call(
Utils::getResquest('apiV4.optin', [], $payload)
);
return $response->status->equals(ApiStatus::OK);
}