From 833d024d99a75518d8ec540635ee2c2bfb1c2db2 Mon Sep 17 00:00:00 2001 From: Alexis Gousseau Date: Wed, 23 Jul 2025 15:55:20 +0200 Subject: [PATCH 1/2] feat: :sparkles: add optionnal answer id parameter when set new single optin --- src/Models/SingleOptin.php | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/Models/SingleOptin.php b/src/Models/SingleOptin.php index 279ef3d..cee2273 100644 --- a/src/Models/SingleOptin.php +++ b/src/Models/SingleOptin.php @@ -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|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); } From 03b18a083f4242283168cd6f9b6b42fffffdd357 Mon Sep 17 00:00:00 2001 From: Alexis Gousseau Date: Fri, 25 Jul 2025 10:16:49 +0200 Subject: [PATCH 2/2] =?UTF-8?q?chore:=20=F0=9F=94=96=20release=20v4.1.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 665e22d..72c27c5 100644 --- a/composer.json +++ b/composer.json @@ -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",