Skip to content

Commit

Permalink
Merge pull request #71 from sendpulse/create_campaign_with_attachment…
Browse files Browse the repository at this point in the history
…s_binary

create campaign with attachments binary
  • Loading branch information
bilovol authored Jul 1, 2021
2 parents 11473bb + eedaad1 commit 5b9b25f
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/ApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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;
Expand All @@ -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;
}
Expand Down

0 comments on commit 5b9b25f

Please sign in to comment.