Code Duplication    Length = 18-22 lines in 2 locations

src/Drivers/MailjetDriver.php 2 locations

@@ 201-218 (lines=18) @@
198
     * @throws ApiError
199
     * @throws InvalidNewsletterList
200
     */
201
    public function unsubscribe(string $email, string $listName = '')
202
    {
203
        $list = $this->lists->findByName($listName);
204
205
        $body = [
206
            'Email' => $email,
207
            'Action' => 'unsub',
208
        ];
209
210
        $response = $this->client->post(Resources::$ContactslistManagecontact, ['id' => $list->getId(), 'body' => $body]);
211
212
        if (! $response->success()) {
213
            $this->lastError = $response->getData();
214
            throw ApiError::responseError($response->getReasonPhrase(), 'mailjet', $response->getStatus());
215
        }
216
217
        return $response;
218
    }
219
220
221
    /**
@@ 228-249 (lines=22) @@
225
     * @throws ApiError
226
     * @throws InvalidNewsletterList
227
     */
228
    public function delete(string $email, string $listName = '')
229
    {
230
        $list = $this->lists->findByName($listName);
231
232
        $body = [
233
            'Email' => $email,
234
            'Action' => 'remove',
235
        ];
236
237
        $response = $this->client->post(Resources::$ContactslistManagecontact, [
238
                'id' => $list->getId(),
239
                'body' => $body
240
            ]
241
        );
242
243
        if (! $response->success()) {
244
            $this->lastError = $response->getData();
245
            throw ApiError::responseError($response->getReasonPhrase(), 'mailjet', $response->getStatus());
246
        }
247
248
        return $response;
249
    }
250
251
    public function getLastError()
252
    {