|
@@ 36-49 (lines=14) @@
|
| 33 |
|
* |
| 34 |
|
* @throws \Spatie\Newsletter\Exceptions\InvalidNewsletterList |
| 35 |
|
*/ |
| 36 |
|
public function subscribe($email, $mergeFields = [], $listName = '', $options = []) |
| 37 |
|
{ |
| 38 |
|
$list = $this->lists->findByName($listName); |
| 39 |
|
|
| 40 |
|
$options = $this->getSubscriptionOptions($email, $mergeFields, $options); |
| 41 |
|
|
| 42 |
|
$response = $this->mailChimp->post("lists/{$list->getId()}/members", $options); |
| 43 |
|
|
| 44 |
|
if (! $this->lastActionSucceeded()) { |
| 45 |
|
return false; |
| 46 |
|
} |
| 47 |
|
|
| 48 |
|
return $response; |
| 49 |
|
} |
| 50 |
|
|
| 51 |
|
/** |
| 52 |
|
* @param string $email |
|
@@ 61-74 (lines=14) @@
|
| 58 |
|
* |
| 59 |
|
* @throws \Spatie\Newsletter\Exceptions\InvalidNewsletterList |
| 60 |
|
*/ |
| 61 |
|
public function subscribeOrUpdate($email, $mergeFields = [], $listName = '', $options = []) |
| 62 |
|
{ |
| 63 |
|
$list = $this->lists->findByName($listName); |
| 64 |
|
|
| 65 |
|
$options = $this->getSubscriptionOptions($email, $mergeFields, $options); |
| 66 |
|
|
| 67 |
|
$response = $this->mailChimp->put("lists/{$list->getId()}/members/{$this->getSubscriberHash($email)}", $options); |
| 68 |
|
|
| 69 |
|
if (! $this->lastActionSucceeded()) { |
| 70 |
|
return false; |
| 71 |
|
} |
| 72 |
|
|
| 73 |
|
return $response; |
| 74 |
|
} |
| 75 |
|
|
| 76 |
|
/** |
| 77 |
|
* @param string $email |