call($request); return $response->status->equals(ApiStatus::OK()); } /** * * Get a customer from its hashcode or email * If it does not exists a new instance * will be returned. You would have * to call its save method later on. * * @param string $identification The customer hashcode or email. * @return \LDC\LDCCRM\Models\Customer A client Customer model. * * @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. * @phpcs:ignore Squiz.Commenting.FunctionComment.EmptyThrows */ public function getCustomerOrNew(string $identification): Customer { return $this->getCustomer($identification) ?? new Customer(); } /** * Get a customer from its hashcode or email * If it does not exists a new instance * will be returned. You would have * to call its save method later on. * * @param string $identification The customer hashcode or email. * @return \LDC\LDCCRM\Models\Customer|null Return null if the customer was not found * @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 : - modelNotFound, If this customer hashcode could not be found. * @phpcs:ignore Squiz.Commenting.FunctionCommentThrowTag.WrongNumber */ public function getCustomer(string $identification): ?Customer { return Customer::find($identification); } /** * Set the single optin 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. * @phpcs:ignore Squiz.Commenting.FunctionCommentThrowTag.WrongNumber */ public static function setStatus(string $email, bool $opt_in): bool { return SingleOptin::setStatus($email, $opt_in); } /** * Set the single optin status for an email * * @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 : - modelNotFound, If a single optin does not exists. * @phpcs:ignore Squiz.Commenting.FunctionCommentThrowTag.WrongNumber */ public static function unsetStatusWithHashcode(string $hashcode): bool { return SingleOptin::unsetStatusWithHashcode($hashcode); } /** * Test a customer credentials to see if it can login * * @param string $email * @param string $password * @return boolean * @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 : - authFailed, If credentials are not valid. * - customerNotActivated, If the account is not activated. * @phpcs:ignore Squiz.Commenting.FunctionCommentThrowTag.WrongNumber */ public static function login(string $email, string $password): bool { return Customer::login($email, $password); } }