| @@ 172-188 (lines=17) @@ | ||
| 169 | * @return Response |
|
| 170 | * @throws ApiError |
|
| 171 | */ |
|
| 172 | public function unsubscribe(string $email, string $listName = '') |
|
| 173 | { |
|
| 174 | $list = $this->lists->findByName($listName); |
|
| 175 | ||
| 176 | $body = [ |
|
| 177 | 'Email' => "${email}", |
|
| 178 | 'Action' => "unsub", |
|
| 179 | ]; |
|
| 180 | ||
| 181 | $response = $this->client->post(Resources::$ContactslistManagecontact, ['id' => $list->getId(), 'body' => $body]); |
|
| 182 | ||
| 183 | if (! $response->success()) { |
|
| 184 | throw ApiError::responseError($response->getReasonPhrase(), 'mailjet', $response->getStatus()); |
|
| 185 | } |
|
| 186 | ||
| 187 | return $response; |
|
| 188 | } |
|
| 189 | ||
| 190 | ||
| 191 | /** |
|
| @@ 197-217 (lines=21) @@ | ||
| 194 | * @return Response |
|
| 195 | * @throws ApiError |
|
| 196 | */ |
|
| 197 | public function delete(string $email, string $listName = '') |
|
| 198 | { |
|
| 199 | $list = $this->lists->findByName($listName); |
|
| 200 | ||
| 201 | $body = [ |
|
| 202 | 'Email' => "${email}", |
|
| 203 | 'Action' => "remove", |
|
| 204 | ]; |
|
| 205 | ||
| 206 | $response = $this->client->post(Resources::$ContactslistManagecontact, [ |
|
| 207 | 'id' => $list->getId(), |
|
| 208 | 'body' => $body |
|
| 209 | ] |
|
| 210 | ); |
|
| 211 | ||
| 212 | if (! $response->success()) { |
|
| 213 | throw ApiError::responseError($response->getReasonPhrase(), 'mailjet', $response->getStatus()); |
|
| 214 | } |
|
| 215 | ||
| 216 | return $response; |
|
| 217 | } |
|
| 218 | ||
| 219 | public function getApi() |
|
| 220 | { |
|