*/ abstract class SingleOptin extends CrmClientModel { /** * Validation rules * * @var array */ protected static $validation = [ 'email' => 'required|email', 'hashcode' => 'required|string|size:36', 'opt_in' => 'required|bool', ]; /** * Set the single opt in status for an email * * @param string $email * @param boolean $opt_in * @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(string $email, bool $opt_in): bool { self::validateValue('email', $email); static::setUpApiInterface(); $request = Utils::getResquest('apiV2.optin', [], [ 'email' => $email, 'opt_in' => $opt_in ]); $response = static::$apiInterface->call($request); return $response->status->equals(ApiStatus::OK()); } /** * Unset the single opt in for a hashcode (unsubscribe) * * @param string $hashcode * @return boolean true if succeeded * @throws \LDC\LDCCRM\Exceptions\ValidationException If a field hashcode 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 unsetStatusWithHashcode(string $hashcode): bool { self::validateValue('hashcode', $hashcode); static::setUpApiInterface(); $request = Utils::getResquest('apiV2.optout-hashcode', [], [ 'hashcode' => $hashcode ]); $response = static::$apiInterface->call($request); return $response->status->equals(ApiStatus::OK()); } }