Skip to content

Commit 751fbe7

Browse files
committed
force Campaigns::addContent fields
1 parent 2564441 commit 751fbe7

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/Api/Campaigns.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace MailerLiteApi\Api;
44

55
use MailerLiteApi\Common\ApiAbstract;
6+
use MailerLiteApi\Exceptions\MailerLiteSdkException;
67

78
/**
89
* Class Campaigns
@@ -18,11 +19,17 @@ class Campaigns extends ApiAbstract {
1819
*
1920
* @param int $campaignId
2021
* @param array $contentData
21-
* @param array $params
2222
* @return [type]
2323
*/
24-
public function addContent($campaignId, $contentData = [], $params = [])
24+
public function addContent(int $campaignId, array $contentData)
2525
{
26+
if ( ! array_key_exists('html', $contentData)) {
27+
throw new MailerLiteSdkException("HTML must be provided");
28+
}
29+
if ( ! array_key_exists('plain', $contentData)) {
30+
throw new MailerLiteSdkException("Plain text must be provided");
31+
}
32+
2633
$endpoint = $this->endpoint . '/' . $campaignId . '/content';
2734

2835
$response = $this->restClient->put($endpoint, $contentData);
@@ -64,7 +71,7 @@ public function cancel($campaignId)
6471
/**
6572
* Get collection of items
6673
* @param array $fields
67-
* @return [type]
74+
* @return \MailerLiteApi\Common\Collection
6875
*/
6976
public function get($type = 'sent', $fields = ['*'])
7077
{

0 commit comments

Comments
 (0)