Add basic interface for MailerMethod
[MAILPOET-4115]
This commit is contained in:
committed by
Veljko V
parent
eb07872d13
commit
b10c30a7b1
@ -8,7 +8,7 @@ use MailPoet\Mailer\Methods\ErrorMappers\AmazonSESMapper;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
use MailPoetVendor\Swift_Message;
|
||||
|
||||
class AmazonSES {
|
||||
class AmazonSES implements MailerMethod {
|
||||
public $awsAccessKey;
|
||||
public $awsSecretKey;
|
||||
public $awsRegion;
|
||||
@ -93,7 +93,7 @@ class AmazonSES {
|
||||
$this->blacklist = new BlacklistCheck();
|
||||
}
|
||||
|
||||
public function send($newsletter, $subscriber, $extraParams = []) {
|
||||
public function send($newsletter, $subscriber, $extraParams = []): array {
|
||||
if ($this->blacklist->isBlacklisted($subscriber)) {
|
||||
$error = $this->errorMapper->getBlacklistError($subscriber);
|
||||
return Mailer::formatMailerErrorResult($error);
|
||||
|
@ -11,7 +11,7 @@ use MailPoet\Services\AuthorizedEmailsController;
|
||||
use MailPoet\Services\Bridge;
|
||||
use MailPoet\Services\Bridge\API;
|
||||
|
||||
class MailPoet {
|
||||
class MailPoet implements MailerMethod {
|
||||
public $api;
|
||||
public $sender;
|
||||
public $replyTo;
|
||||
@ -42,7 +42,7 @@ class MailPoet {
|
||||
$this->blacklist = new BlacklistCheck();
|
||||
}
|
||||
|
||||
public function send($newsletter, $subscriber, $extraParams = []) {
|
||||
public function send($newsletter, $subscriber, $extraParams = []): array {
|
||||
if ($this->servicesChecker->isMailPoetAPIKeyValid() === false) {
|
||||
return Mailer::formatMailerErrorResult($this->errorMapper->getInvalidApiKeyError());
|
||||
}
|
||||
|
7
mailpoet/lib/Mailer/Methods/MailerMethod.php
Normal file
7
mailpoet/lib/Mailer/Methods/MailerMethod.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace MailPoet\Mailer\Methods;
|
||||
|
||||
interface MailerMethod {
|
||||
public function send($newsletter, $subscriber, $extraParams = []): array;
|
||||
}
|
@ -9,7 +9,7 @@ use MailPoet\Mailer\WordPress\PHPMailerLoader;
|
||||
|
||||
PHPMailerLoader::load();
|
||||
|
||||
class PHPMail {
|
||||
class PHPMail implements MailerMethod {
|
||||
public $sender;
|
||||
public $replyTo;
|
||||
public $returnPath;
|
||||
@ -37,7 +37,7 @@ class PHPMail {
|
||||
$this->blacklist = new BlacklistCheck();
|
||||
}
|
||||
|
||||
public function send($newsletter, $subscriber, $extraParams = []) {
|
||||
public function send($newsletter, $subscriber, $extraParams = []): array {
|
||||
if ($this->blacklist->isBlacklisted($subscriber)) {
|
||||
$error = $this->errorMapper->getBlacklistError($subscriber);
|
||||
return Mailer::formatMailerErrorResult($error);
|
||||
|
@ -12,7 +12,7 @@ use MailPoetVendor\Swift_Plugins_LoggerPlugin;
|
||||
use MailPoetVendor\Swift_Plugins_Loggers_ArrayLogger;
|
||||
use MailPoetVendor\Swift_SmtpTransport;
|
||||
|
||||
class SMTP {
|
||||
class SMTP implements MailerMethod {
|
||||
public $host;
|
||||
public $port;
|
||||
public $authentication;
|
||||
@ -65,7 +65,7 @@ class SMTP {
|
||||
$this->blacklist = new BlacklistCheck();
|
||||
}
|
||||
|
||||
public function send($newsletter, $subscriber, $extraParams = []) {
|
||||
public function send($newsletter, $subscriber, $extraParams = []): array {
|
||||
if ($this->blacklist->isBlacklisted($subscriber)) {
|
||||
$error = $this->errorMapper->getBlacklistError($subscriber);
|
||||
return Mailer::formatMailerErrorResult($error);
|
||||
|
@ -7,7 +7,7 @@ use MailPoet\Mailer\Methods\Common\BlacklistCheck;
|
||||
use MailPoet\Mailer\Methods\ErrorMappers\SendGridMapper;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
class SendGrid {
|
||||
class SendGrid implements MailerMethod {
|
||||
public $url = 'https://api.sendgrid.com/api/mail.send.json';
|
||||
public $apiKey;
|
||||
public $sender;
|
||||
@ -35,7 +35,7 @@ class SendGrid {
|
||||
$this->blacklist = new BlacklistCheck();
|
||||
}
|
||||
|
||||
public function send($newsletter, $subscriber, $extraParams = []) {
|
||||
public function send($newsletter, $subscriber, $extraParams = []): array {
|
||||
if ($this->blacklist->isBlacklisted($subscriber)) {
|
||||
$error = $this->errorMapper->getBlacklistError($subscriber);
|
||||
return Mailer::formatMailerErrorResult($error);
|
||||
|
@ -117,7 +117,7 @@ class MailerTest extends \MailPoetTest {
|
||||
'mailerInstance' => Stub::make(
|
||||
$phpMailClass,
|
||||
['send' => Expected::exactly(1, function() {
|
||||
return true;
|
||||
return ['response' => true];
|
||||
})],
|
||||
$this
|
||||
),
|
||||
@ -130,7 +130,7 @@ class MailerTest extends \MailPoetTest {
|
||||
expect($mailerTask->mailer->mailerInstance instanceof $phpMailClass)
|
||||
->true();
|
||||
// send method should return true
|
||||
expect($mailerTask->send('Newsletter', 'Subscriber'))->true();
|
||||
expect($mailerTask->send('Newsletter', 'Subscriber'))->equals(['response' => true]);
|
||||
}
|
||||
|
||||
public function _after() {
|
||||
|
Reference in New Issue
Block a user