@@ 40-53 (lines=14) @@ | ||
37 | * @throws ApiError |
|
38 | * @throws InvalidNewsletterList |
|
39 | */ |
|
40 | public function subscribe(string $email, array $options = [], string $listName = '') |
|
41 | { |
|
42 | $list = $this->lists->findByName($listName); |
|
43 | ||
44 | $options = $this->getSubscriptionOptions($email, $options); |
|
45 | ||
46 | $response = $this->client->post("lists/{$list->getId()}/members", $options); |
|
47 | ||
48 | if (! $this->client->success()) { |
|
49 | throw ApiError::responseError($this->client->getLastError(), 'mailchimp'); |
|
50 | } |
|
51 | ||
52 | return $response; |
|
53 | } |
|
54 | ||
55 | ||
56 | /** |
|
@@ 64-77 (lines=14) @@ | ||
61 | * @throws ApiError |
|
62 | * @throws InvalidNewsletterList |
|
63 | */ |
|
64 | public function subscribeOrUpdate(string $email, array $options = [], string $listName = '') |
|
65 | { |
|
66 | $list = $this->lists->findByName($listName); |
|
67 | ||
68 | $options = $this->getSubscriptionOptions($email, $options); |
|
69 | ||
70 | $response = $this->client->put("lists/{$list->getId()}/members/{$this->getSubscriberHash($email)}", $options); |
|
71 | ||
72 | if (! $this->client->success()) { |
|
73 | throw ApiError::responseError($this->client->getLastError(), 'mailchimp'); |
|
74 | } |
|
75 | ||
76 | return $response; |
|
77 | } |
|
78 | ||
79 | public function addMember(string $email, array $options = [], string $listName = '') |
|
80 | { |