Convert variable names to camel case
[MAILPOET-1796]
This commit is contained in:
@ -21,47 +21,47 @@ class SendGrid {
|
||||
|
||||
private $wp;
|
||||
|
||||
public function __construct($api_key, $sender, $reply_to, SendGridMapper $error_mapper) {
|
||||
$this->api_key = $api_key;
|
||||
public function __construct($apiKey, $sender, $replyTo, SendGridMapper $errorMapper) {
|
||||
$this->apiKey = $apiKey;
|
||||
$this->sender = $sender;
|
||||
$this->reply_to = $reply_to;
|
||||
$this->error_mapper = $error_mapper;
|
||||
$this->replyTo = $replyTo;
|
||||
$this->errorMapper = $errorMapper;
|
||||
$this->wp = new WPFunctions();
|
||||
$this->blacklist = new BlacklistCheck();
|
||||
}
|
||||
|
||||
public function send($newsletter, $subscriber, $extra_params = []) {
|
||||
public function send($newsletter, $subscriber, $extraParams = []) {
|
||||
if ($this->blacklist->isBlacklisted($subscriber)) {
|
||||
$error = $this->error_mapper->getBlacklistError($subscriber);
|
||||
$error = $this->errorMapper->getBlacklistError($subscriber);
|
||||
return Mailer::formatMailerErrorResult($error);
|
||||
}
|
||||
$result = $this->wp->wpRemotePost(
|
||||
$this->url,
|
||||
$this->request($newsletter, $subscriber, $extra_params)
|
||||
$this->request($newsletter, $subscriber, $extraParams)
|
||||
);
|
||||
if (is_wp_error($result)) {
|
||||
$error = $this->error_mapper->getConnectionError($result->get_error_message());
|
||||
$error = $this->errorMapper->getConnectionError($result->get_error_message());
|
||||
return Mailer::formatMailerErrorResult($error);
|
||||
}
|
||||
if ($this->wp->wpRemoteRetrieveResponseCode($result) !== 200) {
|
||||
$response = json_decode($result['body'], true);
|
||||
$error = $this->error_mapper->getErrorFromResponse($response, $subscriber);
|
||||
$error = $this->errorMapper->getErrorFromResponse($response, $subscriber);
|
||||
return Mailer::formatMailerErrorResult($error);
|
||||
}
|
||||
return Mailer::formatMailerSendSuccessResult();
|
||||
}
|
||||
|
||||
public function getBody($newsletter, $subscriber, $extra_params = []) {
|
||||
public function getBody($newsletter, $subscriber, $extraParams = []) {
|
||||
$body = [
|
||||
'to' => $subscriber,
|
||||
'from' => $this->sender['from_email'],
|
||||
'fromname' => $this->sender['from_name'],
|
||||
'replyto' => $this->reply_to['reply_to_email'],
|
||||
'replyto' => $this->replyTo['reply_to_email'],
|
||||
'subject' => $newsletter['subject'],
|
||||
];
|
||||
$headers = [];
|
||||
if (!empty($extra_params['unsubscribe_url'])) {
|
||||
$headers['List-Unsubscribe'] = '<' . $extra_params['unsubscribe_url'] . '>';
|
||||
if (!empty($extraParams['unsubscribe_url'])) {
|
||||
$headers['List-Unsubscribe'] = '<' . $extraParams['unsubscribe_url'] . '>';
|
||||
}
|
||||
if ($headers) {
|
||||
$body['headers'] = json_encode($headers);
|
||||
@ -76,11 +76,11 @@ class SendGrid {
|
||||
}
|
||||
|
||||
public function auth() {
|
||||
return 'Bearer ' . $this->api_key;
|
||||
return 'Bearer ' . $this->apiKey;
|
||||
}
|
||||
|
||||
public function request($newsletter, $subscriber, $extra_params = []) {
|
||||
$body = $this->getBody($newsletter, $subscriber, $extra_params);
|
||||
public function request($newsletter, $subscriber, $extraParams = []) {
|
||||
$body = $this->getBody($newsletter, $subscriber, $extraParams);
|
||||
return [
|
||||
'timeout' => 10,
|
||||
'httpversion' => '1.1',
|
||||
|
Reference in New Issue
Block a user