| 1 |
<?php |
| 2 |
|
| 3 |
use AcyMailing\Core\AcymPlugin; |
| 4 |
|
| 5 |
class SendinblueClass extends AcymPlugin |
| 6 |
{ |
| 7 |
protected array $headers; |
| 8 |
public plgAcymSendinblue $plugin; |
| 9 |
|
| 10 |
public function __construct(&$plugin, $headers = []) |
| 11 |
{ |
| 12 |
parent::__construct(); |
| 13 |
$this->plugin = &$plugin; |
| 14 |
$this->headers = $headers; |
| 15 |
} |
| 16 |
|
| 17 |
protected function callApiSendingMethod(string $url, array $data = [], array $headers = [], string $type = 'GET', array $authentication = [], bool $dataDecoded = false): array |
| 18 |
{ |
| 19 |
$response = parent::callApiSendingMethod(plgAcymSendinblue::SENDING_METHOD_API_URL.$url, $data, $headers, $type, $authentication, $dataDecoded); |
| 20 |
|
| 21 |
$backtrace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 2); |
| 22 |
if (!empty($response['error_curl'])) { |
| 23 |
if (!$backtrace[0]['file'] && !empty($backtrace[1]['function'])) { |
| 24 |
$this->plugin->errors[] = $backtrace[0]['file'].': '.$backtrace[1]['function']; |
| 25 |
} |
| 26 |
acym_logError('Error calling the URL '.$url.': '.$response['error_curl'], 'sendinblue'); |
| 27 |
$this->plugin->errors[] = $response['error_curl']; |
| 28 |
} elseif (!empty($response['message'])) { |
| 29 |
acym_logError('Error calling the URL '.$url.': '.$response['message'], 'sendinblue'); |
| 30 |
|
| 31 |
if (strpos($response['message'], 'Contact already in list') === false) { |
| 32 |
if (!$backtrace[0]['file'] && !empty($backtrace[1]['function'])) { |
| 33 |
$this->plugin->errors[] = $backtrace[0]['file'].': '.$backtrace[1]['function']; |
| 34 |
} |
| 35 |
$this->plugin->errors[] = $response['message']; |
| 36 |
} |
| 37 |
|
| 38 |
if (strpos($response['message'], 'Your account is under validation.') !== false) { |
| 39 |
$this->config->saveConfig(['sendinblue_validation' => 1]); |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
return $response; |
| 44 |
} |
| 45 |
} |
| 46 |
|