From eedaad12f21bc94a620784854926f1a431ae11a3 Mon Sep 17 00:00:00 2001 From: bilovol Date: Thu, 1 Jul 2021 11:53:23 +0300 Subject: [PATCH] attach binary support --- src/ApiClient.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/ApiClient.php b/src/ApiClient.php index d376738..e2d674c 100755 --- a/src/ApiClient.php +++ b/src/ApiClient.php @@ -561,11 +561,12 @@ public function campaignStatByReferrals($id) * @param $bodyOrTemplateId * @param $bookId * @param string $name - * @param string $attachments + * @param array $attachments * @param string $type * @param bool $useTemplateId * @param string $sendDate * @param int|null $segmentId + * @param array $attachmentsBinary * @return mixed */ public function createCampaign( @@ -575,21 +576,18 @@ public function createCampaign( $bodyOrTemplateId, $bookId, $name = '', - $attachments = '', + $attachments = [], $type = '', $useTemplateId = false, $sendDate = '', - $segmentId = null + $segmentId = null, + $attachmentsBinary = [] ) { if (empty($senderName) || empty($senderEmail) || empty($subject) || empty($bodyOrTemplateId) || empty($bookId)) { return $this->handleError('Not all data.'); } - if (!empty($attachments)) { - $attachments = serialize($attachments); - } - if ($useTemplateId) { $paramName = 'template_id'; $paramValue = $bodyOrTemplateId; @@ -605,10 +603,15 @@ public function createCampaign( $paramName => $paramValue, 'list_id' => $bookId, 'name' => $name, - 'attachments' => $attachments, 'type' => $type, ); + if (!empty($attachments)) { + $data['attachments'] = $attachments; + } elseif (!empty($attachmentsBinary)) { + $data['attachments_binary'] = $attachmentsBinary; + } + if (!empty($sendDate)) { $data['send_date'] = $sendDate; }