1 | <?php namespace DiegoCaprioli\Larachimp\Services; |
||
9 | class MailchimpManager |
||
10 | { |
||
11 | /** |
||
12 | * The ID of the Mailchimp list to use to subscribe and unsubscribe members. |
||
13 | * |
||
14 | * @var string |
||
15 | */ |
||
16 | private $listId; |
||
17 | |||
18 | /** |
||
19 | * Make this class use a logger and it's basic methods |
||
20 | */ |
||
21 | use BasicLogging; |
||
22 | |||
23 | |||
24 | /** |
||
25 | * Returns a new MailchimpManager instance ready to use. |
||
26 | * |
||
27 | * @param \Illuminate\Contracts\Logging\Log $log |
||
28 | */ |
||
29 | 5 | public function __construct(Log $log = null) |
|
35 | |||
36 | /** |
||
37 | * Verifies that the list_id corresponds to a valid list in the connected |
||
38 | * Mailchimp account. |
||
39 | */ |
||
40 | 5 | protected function verifyList() |
|
53 | |||
54 | /** |
||
55 | * Returns the stdClass representing the Mailchimp List Member searched by |
||
56 | * email exact match. Returns null if no match is found. |
||
57 | * The returned stdClass has the fields as Mailchimp return for it's members |
||
58 | * under the exact_matches.members entry. |
||
59 | * |
||
60 | * @param string $email The email of the Mailchim member to search for |
||
61 | * |
||
62 | * @return stdClass|null |
||
63 | * |
||
64 | * @see http://developer.mailchimp.com/documentation/mailchimp/reference/search-members/ |
||
65 | */ |
||
66 | 5 | public function searchMember($email) |
|
89 | |||
90 | /** |
||
91 | * Adds the $member to the Mailchimp List. |
||
92 | * |
||
93 | * @param LarachimpListMember $member The onbject isntance to add as a list member |
||
94 | * |
||
95 | * @return stdClass The Mailchimp member |
||
96 | */ |
||
97 | 5 | public function addListMember(LarachimpListMember $member) |
|
107 | |||
108 | /** |
||
109 | * Updates the subscription status of the list member. |
||
110 | * |
||
111 | * @param LarachimpListMember $member The object instance that corresponds to the Mailchimp member |
||
112 | * @param string $subscriberHash The ID in Mailchimp for this subscriber |
||
113 | * |
||
114 | * @return stdClass The Mailchimp member |
||
115 | */ |
||
116 | 1 | public function updateListMember(LarachimpListMember $member, $subscriberHash) |
|
124 | |||
125 | |||
126 | /** |
||
127 | * Removes the member from the mailchimp list, by email |
||
128 | * |
||
129 | * @param string $email The email to remove from the list |
||
130 | */ |
||
131 | 5 | public function removeListMember($email) |
|
141 | |||
142 | |||
143 | /** |
||
144 | * Syncs the member to the Mailchimp List Member's data. Subscribes or |
||
145 | * unsubscribes and adds new members if they don't exists yet. |
||
146 | * |
||
147 | * @param LarachimpListMember $member The object instance that corresponds to the Mailchimp member and should be synced |
||
148 | * @return stdClass The Mailchimp member |
||
149 | */ |
||
150 | 5 | public function syncMember(LarachimpListMember $member) |
|
172 | |||
173 | |||
174 | /** |
||
175 | * [updateMembersEmail description] |
||
176 | * @param LarachimpListMember $member The LarachimpListMember with the new email address |
||
177 | * @param string $oldEmail The old email address that the $member was registered with |
||
178 | * @return stdClass The Mailchimp member |
||
179 | */ |
||
180 | 2 | public function updateMembersEmail(LarachimpListMember $member, $oldEmail) |
|
200 | |||
201 | } |
||
202 |