| 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( |
| 18 |
string $url, |
| 19 |
array $data = [], |
| 20 |
array $headers = [], |
| 21 |
string $type = 'GET', |
| 22 |
array $authentication = [], |
| 23 |
bool $dataDecoded = false, |
| 24 |
array $files = [] |
| 25 |
): array { |
| 26 |
$response = parent::callApiSendingMethod(plgAcymSendinblue::SENDING_METHOD_API_URL.$url, $data, $headers, $type, $authentication, $dataDecoded, $files); |
| 27 |
|
| 28 |
if (!empty($response['error_curl'])) { |
| 29 |
acym_logError('Error calling the URL '.$url.': '.$response['error_curl'], 'sendinblue'); |
| 30 |
$this->plugin->errors[] = $response['error_curl']; |
| 31 |
} elseif (!empty($response['message'])) { |
| 32 |
acym_logError('Error calling the URL '.$url.': '.$response['message'], 'sendinblue'); |
| 33 |
|
| 34 |
if (strpos($response['message'], 'Contact already in list') === false) { |
| 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 |
* Any API call |
| 43 |
* code: unauthorized |
| 44 |
* message: Key not found |
| 45 |
* |
| 46 |
* User creation |
| 47 |
* code: invalid_parameter |
| 48 |
* message: Invalid email address |
| 49 |
* |
| 50 |
* User delete |
| 51 |
* code: document_not_found |
| 52 |
* message: Contact does not exist |
| 53 |
* |
| 54 |
* create attribute |
| 55 |
* code: invalid_parameter |
| 56 |
* message: Attribute name must be unique |
| 57 |
* |
| 58 |
* Add user to list |
| 59 |
* code: invalid_parameter |
| 60 |
* message: Contact already in list and/or does not exist |
| 61 |
* |
| 62 |
* Create list |
| 63 |
* code: document_not_found |
| 64 |
* message: Folder ID does not exist |
| 65 |
* |
| 66 |
* Campaign creation |
| 67 |
* message: Your account is under validation. You can not create another campaign. |
| 68 |
*/ |
| 69 |
} |
| 70 |
|
| 71 |
return $response; |
| 72 |
} |
| 73 |
} |
| 74 |
|