Extract email authorization error messages from bridge to strings

As a part of those changes I tried to unify the array key with error messages.
[MAILPOET-4639]
This commit is contained in:
Jan Lysý
2023-01-06 16:46:53 +01:00
committed by Aschepikov
parent 982568445b
commit 2ace6da75b
3 changed files with 34 additions and 23 deletions

View File

@@ -7,7 +7,7 @@ use MailPoet\Mailer\Mailer;
use MailPoet\Mailer\MailerError;
use MailPoet\Mailer\MailerLog;
use MailPoet\Newsletter\NewslettersRepository;
use MailPoet\Services\AuthorizedSenderDomainController;
use MailPoet\Services\Bridge\API;
use MailPoet\Settings\SettingsController;
use MailPoet\Util\Helpers;
@@ -95,13 +95,12 @@ class AuthorizedEmailsController {
throw new \InvalidArgumentException(self::AUTHORIZED_EMAIL_ERROR_PENDING_CONFIRMATION);
}
$finalData = $this->bridge->createAuthorizedEmailAddress($email);
if ($finalData && isset($finalData['error'])) {
throw new \InvalidArgumentException($finalData['error']);
$response = $this->bridge->createAuthorizedEmailAddress($email);
if ($response['status'] === API::AUTHORIZED_EMAIL_STATUS_ERROR) {
throw new \InvalidArgumentException($response['message']);
}
return $finalData;
return $response;
}
public function isEmailAddressAuthorized(string $email): bool {