Skip to content

Commit 5b9b25f

Browse files
authored
Merge pull request #71 from sendpulse/create_campaign_with_attachments_binary
create campaign with attachments binary
2 parents 11473bb + eedaad1 commit 5b9b25f

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/ApiClient.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -561,11 +561,12 @@ public function campaignStatByReferrals($id)
561561
* @param $bodyOrTemplateId
562562
* @param $bookId
563563
* @param string $name
564-
* @param string $attachments
564+
* @param array $attachments
565565
* @param string $type
566566
* @param bool $useTemplateId
567567
* @param string $sendDate
568568
* @param int|null $segmentId
569+
* @param array $attachmentsBinary
569570
* @return mixed
570571
*/
571572
public function createCampaign(
@@ -575,21 +576,18 @@ public function createCampaign(
575576
$bodyOrTemplateId,
576577
$bookId,
577578
$name = '',
578-
$attachments = '',
579+
$attachments = [],
579580
$type = '',
580581
$useTemplateId = false,
581582
$sendDate = '',
582-
$segmentId = null
583+
$segmentId = null,
584+
$attachmentsBinary = []
583585
)
584586
{
585587
if (empty($senderName) || empty($senderEmail) || empty($subject) || empty($bodyOrTemplateId) || empty($bookId)) {
586588
return $this->handleError('Not all data.');
587589
}
588590

589-
if (!empty($attachments)) {
590-
$attachments = serialize($attachments);
591-
}
592-
593591
if ($useTemplateId) {
594592
$paramName = 'template_id';
595593
$paramValue = $bodyOrTemplateId;
@@ -605,10 +603,15 @@ public function createCampaign(
605603
$paramName => $paramValue,
606604
'list_id' => $bookId,
607605
'name' => $name,
608-
'attachments' => $attachments,
609606
'type' => $type,
610607
);
611608

609+
if (!empty($attachments)) {
610+
$data['attachments'] = $attachments;
611+
} elseif (!empty($attachmentsBinary)) {
612+
$data['attachments_binary'] = $attachmentsBinary;
613+
}
614+
612615
if (!empty($sendDate)) {
613616
$data['send_date'] = $sendDate;
614617
}

0 commit comments

Comments
 (0)